Ich habe versucht, sowohl die Kernbibliothek und den einfachen Wrapper um es zu verwenden und beide finden keine Tripel für die gleichen trivialen Sätze.Stanford NLP OpenIE konnte Tripel für einige Sätze nicht identifizieren
Die einfache Wrapper-Code:
for (final Quadruple<String, String, String, Double> tripple : sentence.openie()) {
System.out.println(tripple);
}
und der Code der Kernbibliothek ist their own example usage:
package edu.stanford.nlp.naturalli;
import edu.stanford.nlp.ie.util.RelationTriple;
import edu.stanford.nlp.io.IOUtils;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.semgraph.SemanticGraph;
import edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations;
import edu.stanford.nlp.util.CoreMap;
import edu.stanford.nlp.util.PropertiesUtils;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
/**
* A demo illustrating how to call the OpenIE system programmatically.
*/
public class OpenIEDemo {
private OpenIEDemo() {} // static main
public static void main(String[] args) throws Exception {
// Create the Stanford CoreNLP pipeline
Properties props = PropertiesUtils.asProperties(
"annotators", "tokenize,ssplit,pos,lemma,depparse,natlog,openie"
// , "depparse.model", "edu/stanford/nlp/models/parser/nndep/english_SD.gz"
// "annotators", "tokenize,ssplit,pos,lemma,parse,natlog,openie"
// , "parse.originalDependencies", "true"
);
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// Annotate an example document.
String text;
if (args.length > 0) {
text = IOUtils.slurpFile(args[0]);
} else {
text = "Obama was born in Hawaii. He is our president.";
}
Annotation doc = new Annotation(text);
pipeline.annotate(doc);
// Loop over sentences in the document
int sentNo = 0;
for (CoreMap sentence : doc.get(CoreAnnotations.SentencesAnnotation.class)) {
System.out.println("Sentence #" + ++sentNo + ": " + sentence.get(CoreAnnotations.TextAnnotation.class));
// Print SemanticGraph
System.out.println(sentence.get(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation.class).toString(SemanticGraph.OutputFormat.LIST));
// 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());
}
// Alternately, to only run e.g., the clause splitter:
List<SentenceFragment> clauses = new OpenIE(props).clausesInSentence(sentence);
for (SentenceFragment clause : clauses) {
System.out.println(clause.parseTree.toString(SemanticGraph.OutputFormat.LIST));
}
System.out.println();
}
}
}
Beide Methoden finden verdreifacht die gleichen Tests bestanden und fehlschlagen:
The cat jumped over the fence.: (cat,jumped over,fence,1.0)
The brown dog barked.: FAIL
The apple was eaten by John.: (apple,was eaten by,John,1.0)
Joe ate the ripe apple.: (Joe,ate,ripe apple,1.0)
They named their daughter Natasha.: (They,named,their daughter Natasha,1.0)
Bob sold me her boat.: FAIL
Grandfather left Rosalita and Raoul all his money.: FAIL
Who killed the cat?: FAIL
How many astronauts have walked on the moon?: (astronauts,have walked on,moon,1.0)
Wenn Es schlägt fehl, die Sammlung, die es zurückgibt, ist leer.
Hat jemand ähnliche Probleme und einen Workaround oder alternative Lösungen?
Welche Art von Triple würden Sie für den Satz erwarten _Der braune Hund bellte? _, Der ein direktes Objekt fehlt. Und ich bin mir auch nicht sicher, welche Art von Triple du für _Who eine Katze getötet haben würdest? _. _Bob verkaufte mir ihr Boot_ funktioniert für mich, obwohl es auch das falsche Triple '(Bob, verkauft, ich)' zurückgibt. –
@SebastianSchuster Für _Der braune Hund bellte_ Ich erwartete, dass es zurückgeben würde, was es finden konnte; das Thema ist Hund und Beziehung, die gebellt wird, aber ich nehme an, es würde Sinn ergeben, dass es nichts zurückgeben würde, wenn es nicht alle drei finden könnte. Ich nahm an, dass _Wer die Katze getötet hat _ zurückkommen würde (wer, getötet, Katze), weil wer ein Thema ist. Ich bin nicht sicher, warum Sie in der Lage waren, _Bob verkaufte mir ihr Boot_ Arbeit zu bekommen. Welche Modelle verwendest du? – 64test1234