为什么我的日期提及的 NamedEntityAnnotator 与 CoreNLP 演示的输出不同?
Why does my NamedEntityAnnotator for date mentions differ from CoreNLP demo's output?
从我的以下程序中检测到的日期被分成两个单独的提及,而 CoreNLP demo 的 NER 输出中检测到的日期应该是单一的。我应该在我的程序中编辑什么来纠正这个问题。
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, entitymentions");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
String text = "This software was released on Februrary 5, 2015.";
Annotation document = new Annotation(text);
pipeline.annotate(document);
List<CoreMap> sentences = document.get(SentencesAnnotation.class);
for(CoreMap sentence: sentences) {
List<CoreMap> mentions = sentence.get(MentionsAnnotation.class);
if (mentions != null) {
for (CoreMap mention : mentions) {
System.out.println("== Token=" + mention.get(TextAnnotation.class));
System.out.println("NER=" + mention.get(NamedEntityTagAnnotation.class));
System.out.println("Normalized NER=" + mention.get(NormalizedNamedEntityTagAnnotation.class));
}
}
}
此程序的输出:
== Token=Februrary 5,
NER=DATE
Normalized NER=****0205
== Token=2015
NER=DATE
Normalized NER=2015
CoreNLP 在线演示的输出:
请注意,在线演示显示具有相同 NER 标签的任何连续标记序列属于同一单元。考虑这句话:
The event happened on February 5th January 9th.
此示例在在线演示中生成 "February 5th January 9th" 作为单个 DATE。
但它会将 "February 5th" 和 "January 9th" 识别为单独的实体提及。
您的示例代码正在查看提及项,而不是 NER 块。在线演示未显示提及。
也就是说,我不确定为什么 SUTime 在您的示例中没有将 2 月 5 日和 2015 年连接在一起。感谢您提出这个问题,我将研究改进模块以在未来的版本中解决此问题。
从我的以下程序中检测到的日期被分成两个单独的提及,而 CoreNLP demo 的 NER 输出中检测到的日期应该是单一的。我应该在我的程序中编辑什么来纠正这个问题。
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, entitymentions");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
String text = "This software was released on Februrary 5, 2015.";
Annotation document = new Annotation(text);
pipeline.annotate(document);
List<CoreMap> sentences = document.get(SentencesAnnotation.class);
for(CoreMap sentence: sentences) {
List<CoreMap> mentions = sentence.get(MentionsAnnotation.class);
if (mentions != null) {
for (CoreMap mention : mentions) {
System.out.println("== Token=" + mention.get(TextAnnotation.class));
System.out.println("NER=" + mention.get(NamedEntityTagAnnotation.class));
System.out.println("Normalized NER=" + mention.get(NormalizedNamedEntityTagAnnotation.class));
}
}
}
此程序的输出:
== Token=Februrary 5,
NER=DATE
Normalized NER=****0205
== Token=2015
NER=DATE
Normalized NER=2015
CoreNLP 在线演示的输出:
请注意,在线演示显示具有相同 NER 标签的任何连续标记序列属于同一单元。考虑这句话:
The event happened on February 5th January 9th.
此示例在在线演示中生成 "February 5th January 9th" 作为单个 DATE。
但它会将 "February 5th" 和 "January 9th" 识别为单独的实体提及。
您的示例代码正在查看提及项,而不是 NER 块。在线演示未显示提及。
也就是说,我不确定为什么 SUTime 在您的示例中没有将 2 月 5 日和 2015 年连接在一起。感谢您提出这个问题,我将研究改进模块以在未来的版本中解决此问题。