AttributeError: 'FreqDist' object has no attribute 'inc'

后端 未结 4 1255
鱼传尺愫
鱼传尺愫 2021-01-17 11:19

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 =          


        
4条回答
  •  逝去的感伤
    2021-01-17 11:56

    You should do it like so:

    fd[word] += 1
    

    But usually FreqDist is used like this:

    fd = FreqDist(my_text)
    

    Also look at the examples here:

    http://www.nltk.org/book/ch01.html

提交回复
热议问题