Skip to content

Instantly share code, notes, and snippets.

@kevinreddot
Created October 25, 2016 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kevinreddot/66655e3febb64656ede6a0cb6132089e to your computer and use it in GitHub Desktop.
Save kevinreddot/66655e3febb64656ede6a0cb6132089e to your computer and use it in GitHub Desktop.
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