gpt4 book ai didi

java - 如何提取与 CoreEntityMention 匹配的维基百科实体 (WikiDictAnnotator)

转载 作者:行者123 更新时间:2023-12-02 02:56:09 25 4
gpt4 key购买 nike

我正在一些文本上运行 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());
}
}

最佳答案

您只需添加维基百科页面网址即可。

因此 Neil_Armstrong 映射到 https://en.wikipedia.org/wiki/Neil_Armstrong

关于java - 如何提取与 CoreEntityMention 匹配的维基百科实体 (WikiDictAnnotator),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57073176/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com