Each GrammaticalRelation
has:
String
short name, which should be a lowercase abbreviation of some kind (in the fure mainly Universal Dependency names).String
long name, which should be descriptive.GrammaticalRelation
hierarchy.Pattern
} calledsourcePattern
which matches (parent) nodes from which this GrammaticalRelation
could hold. (Note: this is done with the Java regex Pattern matches()
predicate. The pattern must match the whole node name, and ^
or $
aren't needed. Tregex constructions like __ do not work. Use ".*" to be applicable at all nodes. This prefiltering is used for efficiency.)TregexPattern
s} called targetPatterns
,which describe the local tree structure which must hold between the source node and a target node for the GrammaticalRelation
to apply. (Note: {@code tregex}regular expressions match with the {@code find()} method, whileliteral string label descriptions that are not regular expressions must be {@code equals()}.)targetPatterns
associated with a GrammaticalRelation
are designed as follows. In order to recognize a grammatical relation X holding between nodes A and B in a parse tree, we want to associate with GrammaticalRelation
X a {@link TregexPattern TregexPattern
} such that:PREDICATE
which holds between a clause and its primary verb phrase, we might want to use the pattern {@code "S < VP=target"}, in which the root will match a clause and the node labeled "target"
will match the verb phrase. For a given grammatical relation, the method {@link GrammaticalRelation#getRelatedNodes getRelatedNodes()
}takes a Tree
node as an argument and attempts to return other nodes which have this grammatical relation to the argument node. By default, this method operates as follows: it steps through the patterns in the pattern list, trying to match each pattern against the argument node, until it finds some matches. If a pattern matches, all matching nodes (that is, each node which corresponds to node label "target" in some match) are returned as a list; otherwise the next pattern is tried.
For some grammatical relations, we need more sophisticated logic to identify related nodes. In such cases, {@link GrammaticalRelation#getRelatedNodes getRelatedNodes()
}can be overridden on a per-relation basis using anonymous subclassing.
@see GrammaticalStructure @see EnglishGrammaticalStructure @see EnglishGrammaticalRelations @see edu.stanford.nlp.trees.international.pennchinese.ChineseGrammaticalRelations @author Bill MacCartney @author Galen Andrew (refactoring English-specific stuff) @author Ilya Sherman (refactoring annotation-relation pairing, which is now gone)
|
|