我正在對(duì)一些文本運(yùn)行 CoreNLP,并將找到的實(shí)體與維基百科實(shí)體進(jìn)行匹配。我想重建為找到的實(shí)體提供鏈接和其他有用信息的句子。CoreEntityMention 有一個(gè)entity()方法,但它只返回一個(gè)字符串。Properties props = new Properties();props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,entitylink");// set up pipelinepipeline = new StanfordCoreNLP(props);String doc = "text goes here";pipeline.annotate(doc);// Iterate the sentencesfor (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()); } }
1 回答

蝴蝶不菲
TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超4個(gè)贊
您只需要添加維基百科頁面 url。
所以Neil_Armstrong
映射到https://en.wikipedia.org/wiki/Neil_Armstrong
.
添加回答
舉報(bào)
0/150
提交
取消