ich OpenIE mit der Stanford CoreNLP http://nlp.stanford.edu/software/openie.htmlopenIE Mit Negation extrahieren
Ich bin mit dem folgenden Code basiert auf einem der verfügbaren Demos auf http://stanfordnlp.github.io/CoreNLP/openie.html
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("openie.triple.strict", "false");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// Annotate an example document.
//File inputFile = new File("src/test/resources/0.txt");
//String text = Files.toString(inputFile, Charset.forName("UTF-8"));
String text = "Cats do not drink milk.";
Annotation doc = new Annotation(text);
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());
}
}
}
zu testen, versuche Dies ergibt intuitiv das Tripel
wird extrahiert, das ist das gleiche Ergebnis, das ich mit dem Eingabetext "Katzen trinken Milch." Wenn ich "openie.triple.strict" auf "true" setze, werden überhaupt keine Tripel extrahiert. Gibt es eine Möglichkeit, ein Triple wie Katzen zu extrahieren? nicht trinken Milch ?
Ich bekomme Java-Heap-Size-Fehler mit dem genauen Code! Hatten Sie ein solches Problem? – Raha1986