Skip to content

Instantly share code, notes, and snippets.

@acrymble
Created July 5, 2011 19:26
Show Gist options
  • Save acrymble/1065655 to your computer and use it in GitHub Desktop.
Save acrymble/1065655 to your computer and use it in GitHub Desktop.
Python word list to word-frequency pairs
# Given a list of words, return a dictionary of
# word-frequency pairs.
def wordListToFreqDict(wordlist):
wordfreq = [wordlist.count(p) for p in wordlist]
return dict(zip(wordlist,wordfreq))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment