/** * Get the OpenIE triples associated with this sentence. * Note that this function may be slower than you would expect, as it has to * convert the underlying Protobuf representation back into {@link CoreLabel}s. * * @param props The properties to use for the OpenIE annotator. * @return A collection of {@link RelationTriple} objects representing the OpenIE triples in the sentence. */ public Collection<RelationTriple> openieTriples(Properties props) { document.runOpenie(props); synchronized (impl) { List<CoreLabel> tokens = asCoreLabels(); Annotation doc = document.asAnnotation(); return impl.getOpenieTripleList().stream().map(x -> ProtobufAnnotationSerializer.fromProto(x, doc, this.sentenceIndex())).collect(Collectors.toList()); } }
/** * Get a list of Open IE triples as flat (subject, relation, object, confidence) quadruples. * This is substantially faster than returning {@link RelationTriple} objects, as it doesn't * require converting the underlying representation into {@link CoreLabel}s; but, it also contains * significantly less information about the sentence. * * @see Sentence@openieTriples(Properties) */ public Collection<Quadruple<String, String, String, Double>> openie() { document.runOpenie(this.defaultProps); return impl.getOpenieTripleList().stream() .filter(proto -> proto.hasSubject() && proto.hasRelation() && proto.hasObject()) .map(proto -> Quadruple.makeQuadruple(proto.getSubject(), proto.getRelation(), proto.getObject(), proto.hasConfidence() ? proto.getConfidence() : 1.0)) .collect(Collectors.toList()); }
/** * Get the OpenIE triples associated with this sentence. * Note that this function may be slower than you would expect, as it has to * convert the underlying Protobuf representation back into {@link CoreLabel}s. * * @param props The properties to use for the OpenIE annotator. * @return A collection of {@link RelationTriple} objects representing the OpenIE triples in the sentence. */ public Collection<RelationTriple> openieTriples(Properties props) { document.runOpenie(props); synchronized (impl) { List<CoreLabel> tokens = asCoreLabels(); Annotation doc = document.asAnnotation(); return impl.getOpenieTripleList().stream().map(x -> ProtobufAnnotationSerializer.fromProto(x, doc, this.sentenceIndex())).collect(Collectors.toList()); } }
/** * Get a list of Open IE triples as flat (subject, relation, object, confidence) quadruples. * This is substantially faster than returning {@link RelationTriple} objects, as it doesn't * require converting the underlying representation into {@link CoreLabel}s; but, it also contains * significantly less information about the sentence. * * @see Sentence@openieTriples(Properties) */ public Collection<Quadruple<String, String, String, Double>> openie() { document.runOpenie(this.defaultProps); return impl.getOpenieTripleList().stream() .filter(proto -> proto.hasSubject() && proto.hasRelation() && proto.hasObject()) .map(proto -> Quadruple.makeQuadruple(proto.getSubject(), proto.getRelation(), proto.getObject(), proto.hasConfidence() ? proto.getConfidence() : 1.0)) .collect(Collectors.toList()); }