根据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
是打印的值。