Guest User

Untitled

a guest
Apr 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. import re
  2. import sys
  3. from collections import Counter
  4.  
  5. def read(path):
  6. pat = re.compile(r'\s+')
  7. with open(path, encoding='utf-8') as f:
  8. for line in f:
  9. for word in pat.split(line.rstrip()):
  10. re_word = word.strip(r'\"').strip(r"\'")
  11. if len(re_word) > 0:
  12. yield re_word
  13.  
  14. def main(src):
  15. reader = read(src)
  16. couter = Counter(reader)
  17. print(couter.most_common(10))
  18.  
  19. if __name__ == '__main__':
  20. main(sys.argv[1])
Add Comment
Please, Sign In to add comment