nltk / nltk_book

NLTK Book
http://www.nltk.org/book
403 stars 143 forks source link

Example 4.4 (code_freq_words2.py) typo and Example 4.3 (code_freq_words1.py) outdated link #255

Open data-wombat opened 2 years ago

data-wombat commented 2 years ago

In 4.3, constitution = "http://www.archives.gov/exhibits/charters/constitution_transcript.html" now goes to a redirected homepage, and the following exercises' outputs look very different as a result. The new URL should be https://www.archives.gov/founding-docs/constitution-transcript.

In 4.4. the last two lines of the function are:

freqdist = nltk.FreqDist(word.lower() for word in word_tokenize(text)) return [word for (word, _) in fd.most_common(n)]

In the last line, fd.most_common(n) should be freqdist.most_common(n).

Thank you for the excellent resource.