【问题标题】:Could not find stanford-parser\.jar jar file at .\stanford-corenlp-4.0.0在 .\stanford-corenlp-4.0.0 找不到 stanford-parser\.jar jar 文件
【发布时间】: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 中搜索

标签: java python nlp nltk


【解决方案1】:

这对我有用: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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多