2017-11-04 2 views
0

Die Seite legen nahe, dass ich mehrere Flaggen https://nlp.stanford.edu/software/openie.htmlWie gibt man Flag-Option im Stanford-NLP-Programm?

verwenden können, aber wie es zu benutzen, versuchte ich es auf diese Weise tun

import edu.stanford.nlp.ie.util.RelationTriple; 
import edu.stanford.nlp.ling.CoreAnnotations; 
import edu.stanford.nlp.pipeline.Annotation; 
import edu.stanford.nlp.pipeline.StanfordCoreNLP; 
import edu.stanford.nlp.naturalli.NaturalLogicAnnotations; 
import edu.stanford.nlp.util.CoreMap; 

import java.util.Collection; 
import java.util.Properties; 

/** 
* A demo illustrating how to call the OpenIE system programmatically. 
*/ 
public class OpenIEDemo { 

public static void main(String[] args) throws Exception { 
// Create the Stanford CoreNLP pipeline 
Properties props = new Properties(); 
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,depparse,natlog,openie"); 
props.setProperty("openieformat","ollie"); 
props.setProperty("openieresolve_coref","1"); 
StanfordCoreNLP pipeline = new StanfordCoreNLP(props); 

// Annotate an example document. 
Annotation doc = new Annotation("Obama was born in Hawaii. He is our president."); 
pipeline.annotate(doc); 

// Loop over sentences in the document 
for (CoreMap sentence : doc.get(CoreAnnotations.SentencesAnnotation.class)) { 
    // Get the OpenIE triples for the sentence 
    Collection<RelationTriple> triples = sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class); 
    // Print the triples 
    for (RelationTriple triple : triples) { 
    System.out.println(triple.confidence + "\t" + 
     triple.subjectLemmaGloss() + "\t" + 
     triple.relationLemmaGloss() + "\t" + 
     triple.objectLemmaGloss()); 
    } 
} 
} 
} 

I

props.setProperty("openieformat","ollie"); 
props.setProperty("openieresolve_coref","1"); 

Aber es funktioniert nicht hinzugefügt haben

Antwort

0

Für StanfordCoreNLP werden Flags/Eigenschaften für einzelne Annotatoren mitfestgelegtName. Und boolesche Flags haben den Wert "false" oder "true". Also, was Sie haben, ist in der Nähe richtig, aber muss sein:

props.setProperty("openie.format","ollie"); props.setProperty("openie.resolve_coref","true");

+0

Eine Sache, die ich entdeckte später, glaube ich muss einen anderen annotator dcoref hinzufügen, für eine vollständige Arbeits – Shashwattrivedi

Verwandte Themen