Stanford NER Tagger在NLTK

Cri*_*a23 1 python nltk stanford-nlp

我想在Python中导入Stanford Named Entity Recognizer.这已经在NLTK包中构建.但是,我的代码不起作用:

 from nltk.tag.stanford import NERTagger
 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
 ImportError: cannot import name NERTagger
Run Code Online (Sandbox Code Playgroud)

可能是什么原因?在我阅读的所有文章中,它默认都有效.谢谢.

Luk*_*raf 12

该类已在版本(commit )中重命名为StanfordNERTagger3.0.3190673c7.

因此,nltk >= 3.0.3您需要使用此导入:

from nltk.tag import StanfordNERTagger
Run Code Online (Sandbox Code Playgroud)

(您也可以这样做from nltk.tag.stanford import StanfordNERTagger,但由于它们现在还在nltk.tag模块中提供了方便的导入,这可能是他们想要使用的,导入位置应该不太容易在未来发生这样的变化.)