title: Stanford CoreNLP: How to get RelationTriple triples with only Name Entities (OpenIE)?
body: <p>I'm currently searching in <strong>CoreNLP Open Information Extraction (OpenIE)</strong> for relation triples (Subject, Predicate, Object) that contains <em>only</em> <strong>NameEntities</strong> in the <strong>Subject and Object types</strong>. But I don't know how to get the entity type of the <code>RelationTriple</code> object that is a <code>List&lt;CoreMap&gt;</code>. </p>
  
  <p>Below is the code from <a href="https://stanfordnlp.github.io/CoreNLP/openie.html" rel="nofollow noreferrer">https://stanfordnlp.github.io/CoreNLP/openie.html</a>:</p>
  
  <pre><code>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");
      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 &lt;RelationTriple&gt; triples = sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class);
        // Print the triples
        for (RelationTriple triple : triples) {
        // Here is where I get the entity type from a triple's subject or object
          System.out.println(triple.confidence + "\t" +
              triple.subjectLemmaGloss() + "\t" +
              triple.relationLemmaGloss() + "\t" +
              triple.objectLemmaGloss());
        }
      }
    }
  }
  </code></pre>
  
  <p>If there exists some way to get the <strong>entity type</strong> from <code>RelationTriple</code> class I would be grateful for the help.</p>