【发布时间】:2020-06-04 02:18:14
【问题描述】:
我是 nltk 的新手,似乎正在遵循一个过时的教程来开始使用 nltk 中的 StanfordDependencyParser。
我已经从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-corenlp-4.0.0是./stanford-corenlp-4.0.0吗? -
我都试过了;我认为问题是我的 stanford-corenlp 文件夹没有 stanford-parser.jar,我不确定它是否从我的下载中丢失,或者我需要单独获取它吗?
-
您可以尝试查看有效的 pom 并在 Eclipse 中搜索