我是 nltk 的新手,似乎正在遵循过时的教程来开始使用 nltk 中的 StanleyDependencyParser。
我已经从https://stanfordnlp.github.io/安装了Stanford Core NLP及其英语模型
但是,运行下面的脚本会返回以下错误:
could not find stanford-parser\.jar jar file at .\stanford-corenlp-4.0.0
希望得到任何指点!
在 Python 3.7 中使用 nltk 3.5 和 stanfordcorenlp 4.0.0
脚本附在下面。
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()))
最佳答案
这对我有用: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)
关于java - 无法在 .\stanford-corenlp-4.0.0 找到 stanford-parser\.jar jar 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62185799/