Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. import numpy as np
  2. import re
  3. import os
  4. import glob as glob
  5. import math
  6. from collections import Counter
  7.  
  8. # Einlesen der 4 Dateien:
  9. txt1_file = open('C:/Users/Friedrich/Desktop/Data Science/Data-Science-Pakete in Python/Numpy Texte/Der-Prozeß.txt')
  10. txt1 = txt1_file.read()
  11. txt2_file = open('C:/Users/Friedrich/Desktop/Data Science/Data-Science-Pakete in Python/Numpy Texte/Effi-Briest.txt')
  12. txt2 = txt2_file.read()
  13. txt3_file = open('C:/Users/Friedrich/Desktop/Data Science/Data-Science-Pakete in Python/Numpy Texte/Stopfkuchen.txt')
  14. txt3 = txt3_file.read()
  15. txt4_file = open('C:/Users/Friedrich/Desktop/Data Science/Data-Science-Pakete in Python/Numpy Texte/Wahlverwandtschaften.txt')
  16. txt4 = txt4_file.read()
  17. #
  18. #
  19. ## den Text in eine Liste auf basierend auf den Leerschlägen:
  20. txt1_words = txt1.lower().split(' ')
  21. txt2_words = txt2.lower().split(' ')
  22. txt3_words = txt3.lower().split(' ')
  23. txt4_words = txt4.lower().split(' ')
  24. #
  25. all_words = txt1_words + txt2_words + txt3_words + txt4_words
  26.  
  27.  
  28. counts = Counter(all_words)
  29.  
  30.  
  31. #Ausgeben der 30 häufigsten worte und übergeben in liste
  32. for key, value in counts.items():
  33.     print (value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement