我是Python和NLTK的初学者。我试图从教程中运行以下代码:
from nltk.corpus import gutenberg
from nltk import FreqDist
fd = FreqDist()
for word in gutenberg.words('austen-sense.txt'):
fd.inc(word)
如果运行此命令,将出现以下错误:
AttributeError: 'FreqDist' object has no attribute 'inc'
知道我做错了什么吗?
Tags:
有些功能已被弃用。
所讨论的代码在nltk 2.0.4版本上确实有效
https://pypi.python.org/pypi/nltk/2.0.4
要安装版本2.0.4,请执行以下操作:
要检查安装的版本,请运行以下命令:
你应该这样做:
但通常FreqDist的用法如下:
还请看下面的示例:
http://www.nltk.org/book/ch01.html
对于希望将图书示例更改为NLTK 3.0的用户:
相关问题 更多 >
编程相关推荐