public class RelationTriple extends java.lang.Object implements java.lang.Comparable<RelationTriple>, java.lang.Iterable<CoreLabel>
| Modifier and Type | Class and Description |
|---|---|
static class |
RelationTriple.AsKBEntry
A
RelationTriple, optimized for tasks such as KBP
where we care about named entities, and care about things like provenance and coref. |
static class |
RelationTriple.WithTree
A
RelationTriple, but with the tree saved as well. |
| Modifier and Type | Field and Description |
|---|---|
double |
confidence
An optional score (confidence) for this triple
|
java.util.List<CoreLabel> |
object
The object (third argument) of this triple
|
java.util.List<CoreLabel> |
relation
The relation (second argument) of this triple
|
java.util.List<CoreLabel> |
subject
The subject (first argument) of this triple
|
static java.util.Set<java.lang.String> |
VALID_ADVERB_ARCS
A set of valid arcs denoting an entity we are interested in
|
static java.util.Set<java.lang.String> |
VALID_OBJECT_ARCS
A set of valid arcs denoting an object entity we are interested in
|
static java.util.Set<java.lang.String> |
VALID_SUBJECT_ARCS
A set of valid arcs denoting a subject entity we are interested in
|
| Constructor and Description |
|---|
RelationTriple(java.util.List<CoreLabel> subject,
java.util.List<CoreLabel> relation,
java.util.List<CoreLabel> object) |
RelationTriple(java.util.List<CoreLabel> subject,
java.util.List<CoreLabel> relation,
java.util.List<CoreLabel> object,
double confidence)
Create a new triple with known values for the subject, relation, and object.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<CoreLabel> |
allTokens()
Returns all the tokens in the extraction, in the order subject then relation then object.
|
java.util.Optional<SemanticGraph> |
asDependencyTree()
An optional method, returning the dependency tree this triple was extracted from
|
java.util.List<CoreLabel> |
asSentence()
Return the given relation triple as a flat sentence
|
int |
compareTo(RelationTriple o) |
java.lang.String |
confidenceGloss()
A textual representation of the confidence.
|
boolean |
equals(java.lang.Object o) |
static java.util.List<RelationTriple> |
extract(SemanticGraph parse,
java.util.List<CoreLabel> tokens)
Extract the nominal patterns from this sentence.
|
protected Pair<java.lang.Integer,java.lang.Integer> |
getSpan(java.util.List<CoreLabel> tokens,
java.util.function.Function<CoreLabel,java.lang.Integer> toMin,
java.util.function.Function<CoreLabel,java.lang.Integer> toMax) |
int |
hashCode() |
java.util.Iterator<CoreLabel> |
iterator() |
java.lang.String |
objectGloss()
The object of this relation triple, as a String
|
CoreLabel |
objectHead()
The head of the object of this relation triple.
|
java.lang.String |
objectLemmaGloss()
The object of this relation triple, as a String of the object's lemmas.
|
Pair<java.lang.Integer,java.lang.Integer> |
objectTokenSpan() |
static java.util.Optional<RelationTriple> |
optimizeForKB(RelationTriple input,
java.util.Optional<CoreMap> sentence,
java.util.Map<CoreLabel,java.util.List<CoreLabel>> canonicalMentions) |
java.lang.String |
relationGloss()
The relation of this relation triple, as a String
|
java.lang.String |
relationLemmaGloss()
The relation of this relation triple, as a String of the relation's lemmas.
|
static java.util.Optional<RelationTriple> |
segment(SemanticGraph parse,
java.util.Optional<java.lang.Double> confidence)
Segment the given parse tree, forcing all nodes to be consumed.
|
static java.util.Optional<RelationTriple> |
segment(SemanticGraph parse,
java.util.Optional<java.lang.Double> confidence,
boolean consumeAll)
Try to segment this sentence as a relation triple.
|
java.lang.String |
subjectGloss()
The subject of this relation triple, as a String
|
CoreLabel |
subjectHead()
The head of the subject of this relation triple.
|
java.lang.String |
subjectLemmaGloss()
The subject of this relation triple, as a String of the subject's lemmas.
|
Pair<java.lang.Integer,java.lang.Integer> |
subjectTokenSpan() |
java.lang.String |
toString()
Print a human-readable description of this relation triple, as a tab-separated line
|
public final java.util.List<CoreLabel> subject
public final java.util.List<CoreLabel> relation
public final java.util.List<CoreLabel> object
public final double confidence
public static final java.util.Set<java.lang.String> VALID_SUBJECT_ARCS
public static final java.util.Set<java.lang.String> VALID_OBJECT_ARCS
public static final java.util.Set<java.lang.String> VALID_ADVERB_ARCS
public RelationTriple(java.util.List<CoreLabel> subject, java.util.List<CoreLabel> relation, java.util.List<CoreLabel> object, double confidence)
subject - The subject of this triple; e.g., "cats".relation - The relation of this triple; e.g., "play with".object - The object of this triple; e.g., "yarn".public java.util.List<CoreLabel> allTokens()
public java.lang.String subjectGloss()
public CoreLabel subjectHead()
public java.lang.String subjectLemmaGloss()
public java.lang.String objectGloss()
public CoreLabel objectHead()
public java.lang.String objectLemmaGloss()
public java.lang.String relationGloss()
public java.lang.String relationLemmaGloss()
public java.lang.String confidenceGloss()
protected Pair<java.lang.Integer,java.lang.Integer> getSpan(java.util.List<CoreLabel> tokens, java.util.function.Function<CoreLabel,java.lang.Integer> toMin, java.util.function.Function<CoreLabel,java.lang.Integer> toMax)
public Pair<java.lang.Integer,java.lang.Integer> subjectTokenSpan()
public Pair<java.lang.Integer,java.lang.Integer> objectTokenSpan()
public java.util.Optional<SemanticGraph> asDependencyTree()
public java.util.List<CoreLabel> asSentence()
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic int compareTo(RelationTriple o)
compareTo in interface java.lang.Comparable<RelationTriple>public java.util.Iterator<CoreLabel> iterator()
iterator in interface java.lang.Iterable<CoreLabel>public static java.util.List<RelationTriple> extract(SemanticGraph parse, java.util.List<CoreLabel> tokens)
parse - The parse tree of the sentence to annotate.tokens - The tokens of the sentence to annotate.RelationTriples. Note that these do not have an associated tree with them.NOUN_TOKEN_PATTERNS,
NOUN_DEPENDENCY_PATTERNSpublic static java.util.Optional<RelationTriple> segment(SemanticGraph parse, java.util.Optional<java.lang.Double> confidence, boolean consumeAll)
Try to segment this sentence as a relation triple. This sentence must already match one of a few strict patterns for a valid OpenIE extraction. If it does not, then no relation triple is created. That is, this is not a relation extractor; it is just a utility to segment what is already a (subject, relation, object) triple into these three parts.
parse - The sentence to process, as a dependency tree.confidence - An optional confidence to pass on to the relation triple.consumeAll - if true, force the entire parse to be consumed by the pattern.public static java.util.Optional<RelationTriple> segment(SemanticGraph parse, java.util.Optional<java.lang.Double> confidence)
public static java.util.Optional<RelationTriple> optimizeForKB(RelationTriple input, java.util.Optional<CoreMap> sentence, java.util.Map<CoreLabel,java.util.List<CoreLabel>> canonicalMentions)