Skip to content

Instantly share code, notes, and snippets.

@gibizer
Created December 14, 2019 22:17
Show Gist options
  • Save gibizer/a3a021365bdbbeaf0da02517bd199095 to your computer and use it in GitHub Desktop.
Save gibizer/a3a021365bdbbeaf0da02517bd199095 to your computer and use it in GitHub Desktop.
import collections
import re
with open('sherlock.txt') as f:
words = re.findall(r'\w+', f.read().lower())
counter = collections.Counter(words)
for w, c in counter.most_common(20):
print(w, c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment