Python NLTK对齐导入错误

Ran*_*ert 3 python python-module nltk python-import

我为NLTK的对齐模块得到一个奇怪的导入错误:

$ python2 --version
Python 2.7.10
$ pip2 freeze | grep nltk
nltk==3.2
$ python2
Python 2.7.10 (default, Oct 23 2015, 18:05:06) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>> from nltk.align import AlignedSent
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named align
Run Code Online (Sandbox Code Playgroud)

如您所见,我为python 2.7安装了nltk 3.2.我可以nltk直接导入.但是,我无法访问该align模块.

我知道我使用的import语句是正确的,因为我直接从官方文档中获取它.另外,我查看了从NLTK 2到NLTK 3的接口更改,并没有提到该align模块.


为什么会发生这种情况,我该怎么做才能解决这个问题?

unu*_*tbu 9

从NLTK 3.2版开始,该align模块已重命名为translate.因此使用:

from nltk.translate import AlignedSent
Run Code Online (Sandbox Code Playgroud)