Created
February 27, 2013 18:42
-
-
Save michaeluzzi/5050428 to your computer and use it in GitHub Desktop.
Outputs the words of Kim and Kanye's tweets, sorted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
all_concordance = dict() | |
for line in open('kim-tweets.txt'): | |
line = line.strip() | |
line = line.replace(".", "") | |
line = line.replace(",", "") | |
line_words = line.split(" ") | |
for word in line_words: | |
if word in all_concordance: | |
all_concordance[word] += 1 | |
else: | |
all_concordance[word] = 1 | |
for line in open('kanye-tweets.txt'): | |
line = line.strip() | |
line = line.replace(".", "") | |
line = line.replace(",", "") | |
line_words = line.split(" ") | |
for word in line_words: | |
if word in all_concordance: | |
all_concordance[word] += 1 | |
else: | |
all_concordance[word] = 1 | |
output = "" | |
sorted_concordance = sorted(all_concordance) | |
for word in sorted_concordance: | |
output += word | |
output += " " | |
print output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment