根据StanfordNERTagger上NER的帖子,我使用了以下代码
from nltk.tag import StanfordNERTagger
from nltk.tokenize import word_tokenize
#stanfordClassifierPath='stanford-ner/classifiers/english.all.3class.distsim.crf.ser.gz'
#stanfordPath='stanford-ner/stanford-ner.jar'
st=StanfordNERTagger('/stanford-ner/classifiers/english.all.3class.distsim.crf.ser.gz','stanford-ner/stanford-ner.jar',encoding='utf-8')
text='While in France, Christine Lagarde discussed short-term stimulus efforts in a recent interview with the Wall Street Journal.'
tokenized_text=word_tokenize(text)
classified_text=st.tag(tokenized_text)
print(classified_text)
但是,执行此代码后,我遇到了错误
File "C:\Anaconda3\lib\site-packages\nltk\tag\stanford.py", line 201, in __init__
super(StanfordNERTagger, self).__init__(*args, **kwargs)
TypeError: super(type, obj): obj must be an instance or subtype of type
我无法解决此问题,并且不知道为什么会发生此错误。 感谢有人可以向我解释原因并解决此错误。