1

根据CoreNLP 的 Git,该问题已在某些版本的 CoreNLP 中得到修复,根据我的猜测可能是 3.5.1,因为 NER 被列为更改说明中的更改模块之一。但是,3.5.x 需要跳转到 Java 1.8,我们目前不准备这样做。

另外,免责声明,我也确实发布了该问题,但由于问题已解决,因此可能看不到它。鉴于 SO 是支持 CoreNLP 的官方论坛,我在这里问。

所以我问,解决这个问题的改变是什么?它实际上是否存在于当前版本中,或者还有其他需要做的事情。我需要在不从我当前使用的 3.4.1 升级的情况下解决这个问题。

作为记录,下面的字符串应该表示 2009 年 12 月 3 日 10:00(该字符串中没有给出秒数,因此我们也假设为 00)。

这是堆栈跟踪。

java.lang.NumberFormatException: For input string: "200912031000"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:583)
at java.lang.Integer.valueOf(Integer.java:766)
at edu.stanford.nlp.ie.pascal.ISODateInstance.extractDay(ISODateInstance.java:1107)
at edu.stanford.nlp.ie.pascal.ISODateInstance.extractFields(ISODateInstance.java:398)
at edu.stanford.nlp.ie.pascal.ISODateInstance.<init>(ISODateInstance.java:82)
at edu.stanford.nlp.ie.QuantifiableEntityNormalizer.normalizedDateString(QuantifiableEntityNormalizer.java:363)
at edu.stanford.nlp.ie.QuantifiableEntityNormalizer.normalizedDateString(QuantifiableEntityNormalizer.java:338)
at edu.stanford.nlp.ie.QuantifiableEntityNormalizer.processEntity(QuantifiableEntityNormalizer.java:1018)
at edu.stanford.nlp.ie.QuantifiableEntityNormalizer.addNormalizedQuantitiesToEntities(QuantifiableEntityNormalizer.java:1320)
at edu.stanford.nlp.ie.NERClassifierCombiner.classifyWithGlobalInformation(NERClassifierCombiner.java:145)
at edu.stanford.nlp.ie.AbstractSequenceClassifier.classifySentenceWithGlobalInformation(AbstractSequenceClassifier.java:322)
at edu.stanford.nlp.pipeline.NERCombinerAnnotator.doOneSentence(NERCombinerAnnotator.java:148)
at edu.stanford.nlp.pipeline.SentenceAnnotator.annotate(SentenceAnnotator.java:95)
at edu.stanford.nlp.pipeline.NERCombinerAnnotator.annotate(NERCombinerAnnotator.java:137)
at edu.stanford.nlp.pipeline.AnnotationPipeline.annotate(AnnotationPipeline.java:67)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.annotate(StanfordCoreNLP.java:847)

编辑

我正在再次查看此内容,因为我目前正在处理我的代码的一些 sutime 部分,我可以通过简单地执行以下操作来重现:

    ISODateInstance idi = new ISODateInstance();
    boolean fields = idi.extractFields("200912031000");
    System.out.println(fields);

请注意,这true是打印的值。

4

2 回答 2

0

我看不到斯坦福 CoreNLP 3.4.1 的这个问题。我下载了 3.4.1 发行版并运行了一个数字很长的句子,没有出现任何崩溃。

你能给我一个导致这个崩溃的例句吗?

于 2016-01-26T11:34:40.023 回答
0

好的,让我说一下为什么会出现问题。3.4.1 中的 extractDay() 有两个问题:

  1. Integer.valueOf 在第 1107 行中使用。这会产生我们看到的错误,因为如果将 String 解释为数字,肯定会是 Long。Long.valueOf 在以后的版本中使用。
  2. extractDay 应该返回 False,因为它无法对该字符串执行任何操作。但是,try 块(第 1106 行)位于 for 循环(第 1097 行)内,这意味着在失败后,可以检查更多标记,从而导致该方法最终返回 true。这将允许创建注释,即使从技术上讲,由于解析失败不应创建注释。在以后的版本中,尝试被移到了 for 块之外。

所以唯一的答案是更新到更高版本(虽然我现在还不能更新到更高版本)。

于 2016-09-23T13:52:01.937 回答