Stanford NER Tagger in NLTK

我与影子孤独终老i 提交于 2019-12-01 10:57:02

问题


I am trying to import the Stanford Named Entity Recognizer in Python. This is already built in the NLTK package. However, my code below is not working:

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

What could be the cause? In all articles I read it works by default. Thank you.


回答1:


That class has been renamed to StanfordNERTagger in version 3.0.3 (commit 190673c7).

So for nltk >= 3.0.3 you need to use this import instead:

from nltk.tag import StanfordNERTagger

(You could also do from nltk.tag.stanford import StanfordNERTagger, but since they now also provide a convenience import in the nltk.tag module, that's probably what they want use to use, that import location should be less prone to future changes like this.)



来源:https://stackoverflow.com/questions/34212833/stanford-ner-tagger-in-nltk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!