Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import sys
- from collections import Counter
- def read(path):
- pat = re.compile(r'\s+')
- with open(path, encoding='utf-8') as f:
- for line in f:
- for word in pat.split(line.rstrip()):
- re_word = word.strip(r'\"').strip(r"\'")
- if len(re_word) > 0:
- yield re_word
- def main(src):
- reader = read(src)
- couter = Counter(reader)
- print(couter.most_common(10))
- if __name__ == '__main__':
- main(sys.argv[1])
Add Comment
Please, Sign In to add comment