I have only just downloaded nltk this morning and have already run into a reoccurring problem with my code.
I get,
AttributeError: 'FreqDist' object has no attribute 'inc'
I had the same error with this code,
for word in gutenberg.words(’austen-persuasion.txt’):
fd.inc(word)
but simply changed it to
fd[word] += 1
However, where do I go when faced with the below code?
for word in gutenberg.words(u'austen-persuasion.txt'):
cfd[prev_word].inc(word)
prev_word = word
It's a nested FreqDist. Try changing
cfd[prev_word].inc(word)
to
cfd[prev_word][word] += 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With