我是nltk的新手,似乎正在遵循一个过时的教程来开始在nltk中使用StanfordDependencyParser。
我已经从https://stanfordnlp.github.io/安装了斯坦福核心NLP和他们的英语模型
但是,运行下面的脚本会返回以下错误:
could not find stanford-parser\.jar jar file at .\stanford-corenlp-4.0.0如果有任何建议,我将不胜感激!
将nltk 3.5和stanfordcorenlp 4.0.0与Python 3.7配合使用
脚本附在下面。
from nltk.parse.stanford import StanfordDependencyParser
path_to_jar = '.\stanford-corenlp-4.0.0'
path_to_models_jar = '.\stanford-corenlp-4.0.0\stanford-corenlp-4.0.0-models-english.jar'
dependency_parser = StanfordDependencyParser(path_to_jar=path_to_jar, path_to_models_jar=path_to_models_jar)
result = dependency_parser.raw_parse('I shot an elephant in my pajamas')
dep = list(result)
for item in dep:
print(list(item.triples()))发布于 2020-06-08 08:45:06
这对我很有效: stanford-parser.jar似乎已经被stanford-corenlp-4.0.0.jar取代了
from nltk.parse.stanford import StanfordDependencyParser
path_to_jar = './stanford-corenlp-4.0.0/stanford-corenlp-4.0.0.jar'
path_to_models_jar = './stanford-corenlp-4.0.0/stanford-corenlp-4.0.0-models.jar'
dependency_parser = StanfordDependencyParser(path_to_jar=path_to_jar, path_to_models_jar=path_to_models_jar)https://stackoverflow.com/questions/62185799
复制相似问题