为什么 Sentence parse 只在第一次抛出异常?

Why does a Sentence parse throw an exception only the first time?

我正在使用 edu.stanford.nlp.simple 包为几种不同语言的句子生成解析树。英文和中文模型产生了预期的结果,例如

> val s = new Sentence("The quick brown fox jumps over the lazy dog.")
> s.parse

res1: edu.stanford.nlp.trees.Tree = (ROOT (NP (NP (DT The) (JJ quick) (JJ brown) (NN fox)) (NP (NP (NNS jumps)) (PP (IN over) (NP (DT the) (JJ lazy) (NN dog))))))

(我在这里使用的是 Scala,但这应该没什么区别。)

然而,其他语言(如德语)表现出一种奇怪的行为:

> val p = new Properties()
> p.load(IOUtils.readerFromString("StanfordCoreNLP-german.properties"))
> val s = new Sentence("Ich hoffe, dass es funktionieren wird.")
> s.parse(p)

10:48:34.127 [main] INFO  e.s.nlp.parser.common.ParserGrammar - Loading parser from serialized file edu/stanford/nlp/models/lexparser/germanFactored.ser.gz ... done  [1.4sec].                                                                                                                                    
java.lang.NullPointerException                                                                                                                            
  edu.stanford.nlp.pipeline.ProtobufAnnotationSerializer.toProto(ProtobufAnnotationSerializer.java:672)                                                   
  edu.stanford.nlp.simple.Document.runParse(Document.java:933)                                                                                            
  edu.stanford.nlp.simple.Sentence.parse(Sentence.java:637)                                                                                               
  ammonite.$sess.cmd3$.<init>(cmd3.sc:1)                                                                                                                  
  ammonite.$sess.cmd3$.<clinit>(cmd3.sc)

> s.parse(p)
res4: edu.stanford.nlp.trees.Tree = (ROOT (S (PPER Ich) (VVFIN hoffe) ($, ,) (S (KOUS dass) (PPER es) (VP (VVINF funktionieren)) (VAFIN wird)) ($. .)))

我已经检查了属性 p 以验证它们没有改变——解析器在第一次调用时始终抛出 NullPointerException,然后在之后对同一个句子正确工作。

我查看了 CoreNLP 的源代码,但找不到发生这种情况的明确原因...我想知道我是否遗漏了什么?

我正在使用 Stanford-CoreNLP 版本 3.9.1。我引用的外语模型来自 Maven 存储库,也在 Stanford CoreNLP website.

上讨论过

确认为错误 -- @StanfordNLPHelp 的修复对我有效。