AttributeError: 'module' object has no attribute 'LogicParser' with nltk.LogicParser()

AttributeError: 'module' object has no attribute 'LogicParser' with nltk.LogicParser()

我正在玩 Natural Language Processing with Python 和这一行的示例:

lp = nltk.LogicParser()

生产

AttributeError: 'module' object has no attribute 'LogicParser'

错误信息。我导入了几个 nltk 模块,但我不知道缺少什么。有什么线索吗?

听起来您已经发现了问题,但以防万一:您正在阅读 NLTK 书的第一版,但显然您已经安装了 NLTK 3,它有很多变化。查看 chapter 10 的当前版本以了解正确用法。