1
    import java.io.*;
    import java.util.*;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import edu.stanford.nlp.ie.util.RelationTriple;
    import edu.stanford.nlp.simple.*;
    import java.util.Collection;
    import java.util.Properties;


    public class OpenIEDemo {
          public static void main(String[] args) throws Exception {

                // Create a CoreNLP document
                Document doc = new Document("He received his academic diploma from the Swiss federal polytechnic school (later the Eidgenössische Technische Hochschule, ETH) in Zürich in 1900.");

                // Iterate over the sentences in the document
                for (Sentence sent : doc.sentences()) {
                  // Iterate over the triples in the sentence
                  for (RelationTriple triple : sent.openieTriples()) {
                    // Print the triple
                    System.out.println(triple.confidence + "\t" + "[Subject]" + 
                        triple.subjectLemmaGloss() + "\t" + "[Predicate]" + 
                        triple.relationLemmaGloss() + "\t" + "[Object]" +
                        triple.objectLemmaGloss());
                  }
                }
              }

}

Output:-
1.0 [Subject]he [Predicate]receive [Object]he diploma
1.0 [Subject]he [Predicate]receive [Object]he academic diploma
1.0 [Subject]swiss federal polytechnic school [Predicate]in [Object]Zürich

But the desired output is
1.0 [Subject]He [Predicate]receive [Object]academic diploma from the Swiss federal polytechnic school in Zürich in 1900

0 Answers0