List of usage examples for edu.stanford.nlp.ie.util RelationTriple relationGloss
public String relationGloss()
From source file:edu.illinois.cs.cogcomp.pipeline.handlers.StanfordOpenIEHandler.java
License:Open Source License
@Override protected void addView(TextAnnotation ta) throws AnnotatorException { Annotation document = new Annotation(ta.text); pipeline.annotate(document);//from w w w.ja v a 2 s . co m SpanLabelView vu = new SpanLabelView(viewName, ta); for (CoreMap sentence : document.get(CoreAnnotations.SentencesAnnotation.class)) { Collection<RelationTriple> triples = sentence .get(NaturalLogicAnnotations.RelationTriplesAnnotation.class); for (RelationTriple triple : triples) { Constituent subject = getConstituent(triple.subjectGloss(), triple.subjectTokenSpan(), sentence, ta); subject.addAttribute("subjectGloss", triple.subjectGloss()); subject.addAttribute("subjectLemmaGloss", triple.subjectLemmaGloss()); subject.addAttribute("subjectLink", triple.subjectLink()); Constituent object = getConstituent(triple.objectGloss(), triple.objectTokenSpan(), sentence, ta); object.addAttribute("objectGloss", triple.objectGloss()); object.addAttribute("objectLemmaGloss", triple.objectLemmaGloss()); object.addAttribute("objectLink", triple.objectLink()); Constituent relation = getConstituent(triple.relationGloss(), triple.relationTokenSpan(), sentence, ta); relation.addAttribute("relationGloss", triple.relationGloss()); relation.addAttribute("relationLemmaGloss", triple.relationLemmaGloss()); Relation subj = new Relation("subj", relation, subject, triple.confidence); Relation obj = new Relation("obj", relation, object, triple.confidence); vu.addRelation(subj); vu.addRelation(obj); vu.addConstituent(subject); vu.addConstituent(object); vu.addConstituent(relation); } } ta.addView(viewName, vu); }