案文如下:
约翰说:“窗外有一头大象。”
有没有一种简单的方法可以看出“窗外有一头大象”。是约翰的吗?
发布于 2017-04-15 03:11:54
我们刚刚添加了一个模块来处理这个问题。
您需要从GitHub获得最新的代码。
下面是一些示例代码:
package edu.stanford.nlp.examples;
import edu.stanford.nlp.coref.*;
import edu.stanford.nlp.coref.data.*;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.util.*;
import edu.stanford.nlp.pipeline.*;
import java.util.*;
public class QuoteAttributionExample {
public static void main(String[] args) {
Annotation document =
new Annotation("John said, \"There's an elephant outside the window.\"");
Properties props = new Properties();
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,entitymentions,quote,quoteattribution");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
pipeline.annotate(document);
for (CoreMap quote : document.get(CoreAnnotations.QuotationsAnnotation.class)) {
System.out.println(quote);
System.out.println(quote.get(QuoteAttributionAnnotator.MentionAnnotation.class));
}
}
}这仍在开发中,我们可能会添加一些代码,以便更容易地获得链接到引号的实际文本跨度。
https://stackoverflow.com/questions/43411968
复制相似问题