gpt4 book ai didi

python - 如何导入 Stanford POS Tagger

转载 作者:太空宇宙 更新时间:2023-11-04 10:02:38 37 4
gpt4 key购买 nike

我正在尝试在 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'

我需要改变什么?

最佳答案

似乎参数 path_to_model 的名称已更改为 model_filename。因此,将最后一行替换为:

st = POS_Tag(model_filename=_path_to_model, path_to_jar=_path_to_jar)

或者既然参数是有序的,就这样写:

st = POS_Tag(_path_to_model, _path_to_jar)

关于python - 如何导入 Stanford POS Tagger,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42766351/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com