Formatting

This commit is contained in:
Crista Lopes
2014-01-01 09:25:39 -08:00
parent 5a98f6e999
commit 1fe7f0c9c7

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys, operator, string import sys, operator, string
def characters(filename): def characters(filename):
@@ -21,7 +20,7 @@ def all_words(filename):
if c.isalnum(): if c.isalnum():
word += c.lower() word += c.lower()
else: else:
# We found the end of a word, emit it # We found end of word, emit it
start_char = True start_char = True
yield word yield word
@@ -40,9 +39,7 @@ def count_and_sort(filename):
# #
# The main function # The main function
# #
word_freqs = count_and_sort(sys.argv[1]) word_freqs = count_and_sort(sys.argv[1])
for (w, c) in word_freqs[0:25]:
for tf in word_freqs[0:25]: print w, ' - ', c
print tf[0], ' - ', tf[1]