为了账号安全,请及时绑定邮箱和手机立即绑定

如何提取与 CoreEntityMention匹配的维基百科实体

如何提取与 CoreEntityMention匹配的维基百科实体

萧十郎 2023-03-31 14:32:51
我正在对一些文本运行 CoreNLP,并将找到的实体与维基百科实体进行匹配。我想重建为找到的实体提供链接和其他有用信息的句子。CoreEntityMention 有一个entity()方法,但它只返回一个字符串。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贡献1810条经验 获得超4个赞

您只需要添加维基百科页面 url。

所以Neil_Armstrong映射到https://en.wikipedia.org/wiki/Neil_Armstrong.


查看完整回答
反对 回复 2023-03-31
  • 1 回答
  • 0 关注
  • 66 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信