我正在对一些文本运行 CoreNLP,并将找到的实体与维基百科实体进行匹配。我想重建为找到的实体提供链接和其他有用信息的句子。
CoreEntityMention 有一个entity()方法,但它只返回一个字符串。
Properties props = new Properties();
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,entitylink");
// set up pipeline
pipeline = new StanfordCoreNLP(props);
String doc = "text goes here";
pipeline.annotate(doc);
// Iterate the sentences
for (CoreSentence sentence : doc.sentences()) {
Go through all mentions
for (CoreEntityMention em : sentence.entityMentions()) {
System.out.println(em.sentence());
// Here I would like to extract the Wikipedia entity information
System.out.println(em.entity());
}
}
蝴蝶不菲
相关分类