我正在尝试使用Python中的Stanford POS Tagger。
home = 'U:/ManWin/My Documents/Research Project'
from nltk.tag.stanford import StanfordPOSTagger as POS_Tag
_path_to_model = home + '/stanford-postagger/models/english-bidirectional-distsim.tagger'
_path_to_jar = home + '/stanford-postagger/stanford-postagger.jar'
st = POS_Tag(path_to_model=_path_to_model, path_to_jar=_path_to_jar)
已从答案中复制了最后一行:Python NLTK pos_tag not returning the correct part-of-speech tag
收到以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "U:\Python35\site-packages\nltk\tag\stanford.py", line 136, in __init__
super(StanfordPOSTagger, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'path_to_model'
我需要改变什么?
答案 0 :(得分:3)
参数 int r = (rand() % 3) + 2;
if (r ==2)
g_fan.draw(r); // skin == 2
else
g_fan.draw(1 + r); //skin == 4
的名称似乎已更改为path_to_model
。因此,将最后一行替换为:
model_filename
或者由于参数是有序的,只需写:
st = POS_Tag(model_filename=_path_to_model, path_to_jar=_path_to_jar)