Skip to content

Instantly share code, notes, and snippets.

Created January 11, 2012 07:39
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
NLTK EX 2.20 Write a function word_freq() that takes a word and the name of a section of the Brown Corpus as arguments, and computes the frequency of the word in that section of the corpus.
def word_freq(word, section):
freq = nltk.probability.FreqDist(nltk.corpus.brown.words(categories = section))
word_frequency = freq[word]
return word_frequency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment