我正在嘗試使用Stanford Corenlp工具包來標註文本。我試圖使用這裏提供的代碼:http://stanfordnlp.github.io/CoreNLP/ 它運作良好。問題是當我想要使用嵌入在coreNLP工具包中的共同參考分辨率工具。這是行不通的。我使用了由stanford nlp group發佈的代碼。代碼是在這裏如下:如何獲得斯坦福核心nlp工具包中的Coreference Resolution註釋?
public class CorefExample {
public static void main(String[] args) throws Exception {
Annotation document = new Annotation("Barack Obama was born in Hawaii. He is the president. Obama was elected in 2008.");
Properties props = new Properties();
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,mention,coref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
pipeline.annotate(document);
System.out.println("---");
System.out.println("coref chains");
for (CorefChain cc : document.get(CorefCoreAnnotations.CorefChainAnnotation.class).values()) {
System.out.println("\t"+cc);
}
for (CoreMap sentence : document.get(CoreAnnotations.SentencesAnnotation.class))
{
System.out.println("---");
System.out.println("mentions");
for (Mention m : sentence.get(CorefCoreAnnotations.CorefMentionsAnnotation.class)) {
System.out.println("\t"+m);
}
}
}
}
但是當我要運行這些代碼,我得到空,這條線: 「sentence.get(CorefCoreAnnotations.CorefMentionsAnnotation.class)」 總是返回NULL,而我相信該工具包已經批准了核心提及。 我真的混了起來。解決辦法是什麼?我如何在Java代碼中接收coref annottaion?
爲什麼你需要爲每個句子得到提及的核心參考?當我不得不處理它時,我只是使用CorefChainAnnotation中的信息,並將其與句子信息進行匹配,以檢查鏈中給出的令牌索引。 –
Tx。我的意思是我只需要確定絕對提到,如「奧巴馬和他」。例如,如果我們有:「奧巴馬出生在美國,他是總統,他在2008年當選」,連鎖店是:奧巴馬和美國/奧巴馬和他/總統和2008年。你是如何過濾它的?我想你必須有一個選擇把它交給我。 (作爲corenlp在線演示http://nlp.stanford.edu:8080/corenlp/便於此功能!) –