Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Just a frequency analysis
!/usr/bin/python
import string
t = open("trump", "r")
words = {}
for line in t:
for w in line.split():
word = string.strip(w, ":,.\"").lower()
if word in words:
words[word] += 1
else:
words[word] = 1
for word, _ in sorted(words.items(), key = lambda x: x[1]):
print word, words[word]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.