【问题标题】:IOUtil Error Loading Stanford Shift Reduce ParserIOUtil 错误加载 Stanford Shift Reduce 解析器
【发布时间】:2016-06-02 20:45:58
【问题描述】:

我正在尝试将我的 Stanford CoreNLP 版本升级到最新版本(之前在 v3.5.2 上,尝试升级到 v3.6.0)。在编译了 v3.6.0 所需的所有新 jar 之后,我启动了一个独立的 Stanford CoreNLP 服务器(使用 Apache Thrift v0.9.3)。

此外,我正在使用斯坦福的 Shift Reduce Parser,可以在以下链接中找到它:Stanford Shift Reduce Parser。我相信该模型的最新版本于 2014 年 10 月 23 日发布。我特别需要的模型是englishSR.beam.ser.gz(English Beam Search Shift Reduce Model)。

不幸的是,在运行我的新服务器(Stanford CoreNLP v3.6.0 / Apache Thrift v0.9.3)时,日志显示错误:

Reading in configuration from scripts/config...
Initializing Parser...
Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... done [0.6 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... done [0.5 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... done [1.5 sec].
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/defs.sutime.txt
May 20, 2016 3:41:00 AM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules
INFO: Read 83 rules
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.sutime.txt
May 20, 2016 3:41:01 AM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules
INFO: Read 267 rules
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.holidays.sutime.txt
May 20, 2016 3:41:01 AM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules
INFO: Read 25 rules
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [0.4 sec].
03:41:01.566 [main] ERROR edu.stanford.nlp.io.IOUtils - Loading parser from serialized file edu/stanford/nlp/models/srparser/englishSR.beam.ser.gz ... 
done [10.4 sec].
Initializing Tokenizer...
The CoreNLP server is running...

相反,这是运行旧服务器(Stanford CoreNLP v3.5.2 / Thrift v0.9.3)时看到的日志:

Reading in configuration from scripts/config...
Initializing Parser...
Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... done [1.3 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... done [1.1 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... done [2.7 sec].
Initializing JollyDayHoliday for SUTime from classpath: edu/stanford/nlp/models/sutime/jollyday/Holidays_sutime.xml as sutime.binder.1.
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/defs.sutime.txt
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.sutime.txt
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.holidays.sutime.txt
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [0.5 sec].
Loading parser from serialized file edu/stanford/nlp/models/srparser/englishSR.beam.ser.gz ... done [9.8 sec].
Adding annotator dcoref
Initializing Tokenizer...
The CoreNLP server is running...

如您所见,新服务器在尝试加载 srparser 时出错,并且最终不会出现“添加注释器 dcoref”。我没有修改任何其他文件,也不确定是什么导致了这种差异。目前正在寻找斯坦福核心 NLP 属性文件,但我将不胜感激有关此问题的任何帮助。提前致谢!

【问题讨论】:

  • 确保您的 CLASSPATH 中有英文模型 jar。您可以在此处下载该 jar:stanfordnlp.github.io/CoreNLP/download.html ... 该 jar 肯定包含 shift reduce 解析器文件
  • 另外你可能对此感兴趣:stanfordnlp.github.io/CoreNLP/corenlp-server.html
  • 另外,我不确定你为什么说“用 ant 重建”...如果你想使用 v3.6.0,你只需要 jar stanford-corenlp-3.6.0.jar 和适当的依赖项和模型...您需要的一切都在这里:stanfordnlp.github.io/CoreNLP/download.html
  • 感谢您的快速回复 - 抱歉我的描述有点含糊。在我开始我的项目时,corenlp-server 实现不可用,因此我有一个单独的实现,它使用“ant”来构建一个包装 jar,它封装了我独特设置所需的所有 jar。我肯定打算看看我是否可以在不久的将来切换到您链接的 corenlp-server(开销要少得多)。我相当肯定英国模型罐在那里。但让我仔细检查并报告。
  • 所以在检查了我的罐子后,我似乎确实拥有所需的必要英文模型罐子。在我看来,shift reduce 解析器英语模型存在问题(这是一个单独的实体,位于我在上面提供的链接中:nlp.stanford.edu/software/srparser.shtml)。这个模型是单独提供的,因为它在文件大小方面更大,我想要的是beam search shift reduce parser英文模型。据我所知,这个模型在 3.5.2 和 3.6.0 版本之间没有改变,所以我主要担心的是我缺少一些其他新的依赖项。

标签: java stanford-nlp


【解决方案1】:

我运行了这个命令,没有任何问题:

java -Xmx6g -cp "stanford-corenlp-full-2015-12-09/*:stanford-english-corenlp-2016-01-10-models.jar" edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse -file sample-text.txt -outputFormat text -parse.model edu/stanford/nlp/models/srparser/englishSR.beam.ser.gz

这是使用 Stanford CoreNLP 3.6.0 的发行版和我们使用的最新模型 jar。

如果您的 CLASSPATH 中有旧版本的东西漂浮在您的 CLASSPATH 中,这可能会导致兼容性问题,从而导致无法正常工作,请确保只使用这些 jars 并且仅使用这些 jars。

为了清楚起见,该发行版附带了一个标准模型 jar,其中包含一些基本的东西可以使用该工具包。然后是单独的英文模型jar,它是巨大的,包含所有英文资源。

英语 shift reduce 解析器模型都在我们现在分发的英语模型 jar 中,其中包含所有英语资源。这是获取标准 jar 中不可用的英语资源的推荐方法。我可能需要更新一些页面以反映这些信息。旧的 shift reduce 模型 jar 可能与 3.6.0 不兼容,我会调查。

所有这些东西都可以在这里找到:http://stanfordnlp.github.io/CoreNLP/download.html

如果您仍有问题,请告诉我,让我知道导致问题的 jar 来自何处,我会进行调查。但是,如果您使用从上面链接下载的资源运行该命令,它应该可以正常工作。

【讨论】:

  • 在我的问题底部发布了回复,不确定您是否能够看到它;也许我们可以把它移到聊天中?标准发行版似乎可以独立运行,但我的临时服务器/客户端实现可能是问题......
【解决方案2】:

你调用了 ShiftReduceParser.loadModel 方法吗?

该方法调用IOUtils.readObjectAnnouncingTimingFromURLOrClasspathOrFileSystem方法,其来源如下:

try {
  Timing timing = new Timing();
  logger.error(msg + ' ' + path + " ... ");
  obj = IOUtils.readObjectFromURLOrClasspathOrFileSystem(path);
  timing.done();
} catch (IOException | ClassNotFoundException e) {
  throw new RuntimeIOException(e);
}
return obj;

“logger.error”可能是一个错误。我想应该是“logger.info”。

【讨论】:

  • 我确实调用了 loadModel() 方法,但有点不确定您的要求是什么。您的意思是说错误消息具有误导性吗?即使加载上面列出的模型文件时出现错误,减去似乎没有加载的“dcoref 注释器”所做的 coref 注释,一切似乎都解析得很好。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-28
  • 2023-03-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-05
相关资源
最近更新 更多