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

8
06-code-golf/tf-06-1.py Normal file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env python
import re, string, sys
stops = set(open("../stop_words.txt").read().split(",") + list(string.ascii_lowercase))
words = [x.lower() for x in re.split("[^a-zA-Z]+", open(sys.argv[1]).read()) if len(x) > 0 and x.lower() not in stops]
unique_words = list(set(words))
unique_words.sort(lambda x, y: cmp(words.count(y), words.count(x)))
print "\n".join(["%s - %s" % (x, words.count(x)) for x in unique_words[:25]])