2017-04-14 52 views

回答

2

我們剛剛添加了一個模塊來處理這個問題。

您需要從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)); 
    } 
    } 
} 

這是仍在開發中,我們可能會添加一些代碼,使其更容易得到很快鏈接到報價的實際文本跨度。