Renumber to make the flow better

This commit is contained in:
Crista Lopes
2014-01-05 07:40:17 -08:00
parent ce0bef372e
commit f0445b3c61
13 changed files with 0 additions and 0 deletions

11
06-code-golf/tf-06-pn.py Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env python
# My golf score is slightly lower!
# Best wishes, Peter Norvig
import re, sys, collections
stopwords = set(open('../stop_words.txt').read().split(','))
words = re.findall('[a-z]{2,}', open(sys.argv[1]).read().lower())
counts = collections.Counter(w for w in words if w not in stopwords)
for (w, c) in counts.most_common(25):
print w, '-', c