I am a beginner in Python and NLTK. I am trying to run the following code from a tutorial:
from nltk.corpus import gutenberg
from nltk import FreqDist
fd =
For people looking for how to change the book example to NLTK 3.0:
import nltk
from nltk.corpus import brown
suffix_fdist = nltk.FreqDist()
for word in brown.words():
word = word.lower()
suffix_fdist[word[-1:]] +=1
suffix_fdist[word[-2:]] +=1
suffix_fdist[word[-3:]] +=1
common_suffixes = []
for suffix in suffix_fdist.most_common(100):
common_suffixes.append(str(suffix.__getitem__(0)))
print common_suffixes