異常根據CoreNLP's Git,根據我的猜測,該問題已在某些版本的CoreNLP中得到修復,可能是3.5.1,因爲NER被列爲更改說明中已更改模塊之一。但是,3.5.x需要跳轉到Java 1.8,我們目前還沒有準備好這樣做。意外的日期/日期時間字符串導致在斯坦福CoreNLP
此外,免責聲明,我也發佈了該問題,但它可能沒有被看到,因爲問題已被解決。鑑於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
是打印的值。
我無法真正提供整個文檔,但我希望有問題的行已足夠'DATETIME_END:200912031000'這發生在使用已創建的模型進行測試(分類)中。它被標記爲DATE實體,然後問題發生時,這被視爲一個DATE實體(你可以看到從這個字符串解析一天) – demongolem
另外,我實例化'nerCombiner = new NERClassifierCombiner(applyNumericClassifiers, useSUTime , props,//此參數應該包含SUtime屬性 myClassifierArray);'我發現如果第一個參數是手動設置爲false,則不會發生錯誤。所以大多數我們只是從流水線上訪問NER,但在某些情況下,我們必須自己構建它,這就是這種情況。 – demongolem