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.
This file contains 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
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