在NLTK Python中使用Stanford POS Tagger时出错

B-A*_*asi 11 nltk pos-tagger stanford-nlp python-2.7

我试图在NLTK中使用Stanford POS Tagger,但我无法运行此处给出的示例代码http://www.nltk.org/api/nltk.tag.html#module-nltk.tag.stanford

import nltk
from nltk.tag.stanford import POSTagger
st = POSTagger(r'english-bidirectional-distim.tagger',r'D:/stanford-postagger/stanford-postagger.jar')
st.tag('What is the airspeed of an unladen swallow?'.split())
Run Code Online (Sandbox Code Playgroud)

我已经添加了环境变量

CLASSPATH = D:/stanford-postagger/stanford-postagger.jar
STANFORD_MODELS =  D:/stanford-postagger/models/
Run Code Online (Sandbox Code Playgroud)

这是我不断得到的错误

Traceback(最近一次调用最后一次):

File "D:\pos_stanford.py", line 4, in <module>
    st = POSTagger(r'english-bidirectional-distim.tagger',
         r'D:/stanford-postagger/stanford-postagger.jar')  
... LookupError: NLTK was unable to find the english-bidirectional-distim.tagger file! Use software specific configuration paramaters or set the STANFORD_MODELS environment variable.
Run Code Online (Sandbox Code Playgroud)

一些论坛建议

File "C:\Python27\lib\site-packages\nltk\tag\stanford.py", line 45, in __init__
env_vars=('STANFORD_MODELS'), verbose=verbose)
Run Code Online (Sandbox Code Playgroud)

应该改变,以便有一个逗号

env_vars=('STANFORD_MODELS',), verbose=verbose)
Run Code Online (Sandbox Code Playgroud)

但它也没有解决问题.请帮我解决这个问题.

其他信息:我使用的是Windows 7 64位Python 2.7 32位NLTK 2.0

B-A*_*asi 11

注意:只是将其作为答案发布,以防其他人在将来遇到此问题

我终于发现了我做错了什么......结果证明是一个大错.

Tagger文件名不是'english-bidirectional-distim.tagger',而是'english-bidirectional-distsim.tagger'.