edu.stanford.nlp.trees
Enum GrammaticalRelation

java.lang.Object
  extended by java.lang.Enum<GrammaticalRelation>
      extended by edu.stanford.nlp.trees.GrammaticalRelation
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<GrammaticalRelation>

public enum GrammaticalRelation
extends java.lang.Enum<GrammaticalRelation>

GrammaticalRelation is used to define a standardized, hierarchical set of grammatical relations for the English language, together with patterns for identifying them in parse trees.

Each GrammaticalRelation has:

The 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 TregexPattern such that: For example, for the grammatical relation PREDICATE which holds between a clause and its primary verb phrase, we might want to use the pattern "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 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, getRelatedNodes() can be overridden on a per-relation basis using anonymous subclassing.

This set of English grammatical relations is not intended to be exhaustive or immutable. It's just where we're at now.


Enum Constant Summary
ADJECTIVAL_COMPLEMENT
          The "adjectival complement" grammatical relation.
ADJECTIVAL_MODIFIER
          The "adjectival modifier" grammatical relation.
ADVERBIAL_MODIFIER
          The "adverbial modifier" grammatical relation.
APPOSITIONAL_MODIFIER
          The "appositional modifier" grammatical relation.
ARGUMENT
          The "argument" grammatical relation.
AUX_MODIFIER
          The auxiliary grammatical relation.
CLAUSAL_COMPLEMENT
          The "clausal complement" grammatical relation.
CLAUSAL_SUBJECT
          The "clausal subject" grammatical relation.
COMPLEMENT
          The "complement" grammatical relation.
DEPENDENT
          The "dependent" grammatical relation, which is the inverse of "governor".
DETERMINER
          The "determiner" grammatical relation.
DIRECT_OBJECT
          The "direct object" grammatical relation.
GOVERNOR
          The "governor" grammatical relation, which is the inverse of "dependent".
INDIRECT_OBJECT
          The "indirect object" grammatical relation.
INFINITIVAL_MODIFIER
          The "infinitval modifier" grammatical relation.
MODIFIER
          The "modifier" grammatical relation.
NOMINAL_PASSIVE_SUBJECT
          The "nominal passive subject" grammatical relation.
NOMINAL_SUBJECT
          The "nominal subject" grammatical relation.
NOUN_COMPOUND_MODIFIER
          The "noun compound modifier" grammatical relation.
NUMERIC_MODIFIER
          The "numeric modifier" grammatical relation.
OBJECT
          The "object" grammatical relation.
PARTICIPIAL_MODIFIER
          The "participial modifier" grammatical relation.
PREDICATE
          The "predicate" grammatical relation.
SUBJECT
          The "subject" grammatical relation.
TEMPORAL_MODIFIER
          The "temporal modifier" grammatical relation.
 
Method Summary
 java.util.List<Tree> getRelatedNodes(Tree t)
          Given a Tree node t, attempts to return a list of nodes to which node t has this grammatical relation.
 boolean isAncestor(GrammaticalRelation gr)
           
 boolean isApplicable(Tree t)
          Returns true iff the value of Tree node t matches the sourcePattern for this GrammaticalRelation, indicating that this GrammaticalRelation is one that could hold between Tree node t and some other node.
static void main(java.lang.String[] args)
           
 java.lang.String toPrettyString()
          Returns a String representation of this GrammaticalRelation and the hierarchy below it, with one node per line, indented according to level.
 java.lang.String toString()
          Returns short name (abbreviation) for this GrammaticalRelation.
static GrammaticalRelation valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static GrammaticalRelation[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

GOVERNOR

public static final GrammaticalRelation GOVERNOR
The "governor" grammatical relation, which is the inverse of "dependent".

Example: "the red car" → gov(red, car)


DEPENDENT

public static final GrammaticalRelation DEPENDENT
The "dependent" grammatical relation, which is the inverse of "governor".

Example: "the red car" → dep(car, red)


PREDICATE

public static final GrammaticalRelation PREDICATE
The "predicate" grammatical relation. The predicate of a clause is the main VP of that clause; the predicate of a subject is the predicate of the clause to which the subject belongs.

Example: "Reagan died" → pred(Reagan, died)


AUX_MODIFIER

public static final GrammaticalRelation AUX_MODIFIER
The auxiliary grammatical relation. An auxiliary of a clause is a non-main verb of the clause.

Example: "Reagan has died" → aux(died, has)


ARGUMENT

public static final GrammaticalRelation ARGUMENT
The "argument" grammatical relation. An argument of a VP is a subject or complement of that VP; an argument of a clause is an argument of the VP which is the predicate of that clause.

Example: "Clinton defeated Dole" → arg(defeated, Clinton), arg(defeated, Dole)


SUBJECT

public static final GrammaticalRelation SUBJECT
The "subject" grammatical relation. The subject of a VP is the noun or clause that performs or experiences the VP; the subject of a clause is the subject of the VP which is the predicate of that clause.

Examples: "Clinton defeated Dole" → subj(defeated, Clinton), "What she said is untrue" → subj(is, What she said)


NOMINAL_SUBJECT

public static final GrammaticalRelation NOMINAL_SUBJECT
The "nominal subject" grammatical relation. A nominal subject is a subject which is an noun phrase.

Example: "Clinton defeated Dole" → nsubj(defeated, Clinton),


NOMINAL_PASSIVE_SUBJECT

public static final GrammaticalRelation NOMINAL_PASSIVE_SUBJECT
The "nominal passive subject" grammatical relation. A nominal passive subject is a subject of a passive which is an noun phrase.

Example: "Dole was defeated by Clinton" → nsubjpass(defeated, Dole)


CLAUSAL_SUBJECT

public static final GrammaticalRelation CLAUSAL_SUBJECT
The "clausal subject" grammatical relation. A clausal subject is a subject which is a clause.

Example: "What she said is untrue" → csubj(is, What she said)


COMPLEMENT

public static final GrammaticalRelation COMPLEMENT
The "complement" grammatical relation. A complement of a VP is any object (direct or indirect) of that VP, or a clause or adjectival phrase which functions like an object; a complement of a clause is an complement of the VP which is the predicate of that clause.

Examples: "She gave me a raise" → comp(gave, me), comp(gave, a raise); "I like to swim" → comp(like, to swim)


OBJECT

public static final GrammaticalRelation OBJECT
The "object" grammatical relation. An object of a VP is any direct object or indirect object of that VP; an object of a clause is an object of the VP which is the predicate of that clause.

Examples: "She gave me a raise" → obj(gave, me), obj(gave, a raise)


DIRECT_OBJECT

public static final GrammaticalRelation DIRECT_OBJECT
The "direct object" grammatical relation. The direct object of a VP is the noun phrase which is the (accusative) object of the verb; the direct object of a clause is the direct object of the VP which is the predicate of that clause.

Example: "She gave me a raise" → dobj(gave, a raise)


INDIRECT_OBJECT

public static final GrammaticalRelation INDIRECT_OBJECT
The "indirect object" grammatical relation. The indirect object of a VP is the noun phrase which is the (dative) object of the verb; the indirect object of a clause is the indirect object of the VP which is the predicate of that clause.

Example: "She gave me a raise" → iobj(gave, me)


CLAUSAL_COMPLEMENT

public static final GrammaticalRelation CLAUSAL_COMPLEMENT
The "clausal complement" grammatical relation. A clausal complement of a VP is a clause which functions like an object of the verb; a clausal complement of a clause is the clausal complement of the VP which is the predicate of that clause.

Example: "I like to swim" → ccomp(like, to swim)


ADJECTIVAL_COMPLEMENT

public static final GrammaticalRelation ADJECTIVAL_COMPLEMENT
The "adjectival complement" grammatical relation. An adjectival complement of a VP is a adjectival phrase which functions like an object of the verb; an adjectival complement of a clause is the adjectival complement of the VP which is the predicate of that clause.

Example: "She looks very beautiful" → acomp(looks, very beautiful)


MODIFIER

public static final GrammaticalRelation MODIFIER
The "modifier" grammatical relation. A modifier of a VP is any constituent that serves to modify the meaning of the VP (but is not an ARGUMENT of that VP); a modifier of a clause is an modifier of the VP which is the predicate of that clause.

Examples: "I swam in the pool last night" → mod(swam, in the pool), mod(swam, last night)


TEMPORAL_MODIFIER

public static final GrammaticalRelation TEMPORAL_MODIFIER
The "temporal modifier" grammatical relation. A temporal modifier of a VP is any constituent that serves to modify the meaning of the VP by specifying a time; a temporal modifier of a clause is an temporal modifier of the VP which is the predicate of that clause.

Examples: "I swam in the pool last night" → tmod(swam, last night)


ADJECTIVAL_MODIFIER

public static final GrammaticalRelation ADJECTIVAL_MODIFIER
The "adjectival modifier" grammatical relation. An adjectival modifier of an NP is any adjectival phrase that serves to modify the meaning of the NP.

Examples: "Sam eats red meat" → amod(meat, red)


NUMERIC_MODIFIER

public static final GrammaticalRelation NUMERIC_MODIFIER
The "numeric modifier" grammatical relation. A numeric modifier of an NP is any number phrase that serves to modify the meaning of the NP.

Examples: "Sam eats 3 sheep" → num(sheep, 3)


NOUN_COMPOUND_MODIFIER

public static final GrammaticalRelation NOUN_COMPOUND_MODIFIER
The "noun compound modifier" grammatical relation. A noun compound modifier of an NP is any noun that serves to modify the head noun. Note that this has all nouns modify the rightmost a la Penn headship rules. There is no intelligent noun compound analysis.

Example: "Oil price futures" nn(futures, oil) nn(futures, price)


APPOSITIONAL_MODIFIER

public static final GrammaticalRelation APPOSITIONAL_MODIFIER
The "appositional modifier" grammatical relation. An appositional modifier of an NP is an NP that serves to modify the meaning of the NP.

Examples: "Sam, my brother, eats red meat" → appos(Sam, brother)


PARTICIPIAL_MODIFIER

public static final GrammaticalRelation PARTICIPIAL_MODIFIER
The "participial modifier" grammatical relation. A participial modifier of an NP is a VP that serves to modify the meaning of the NP.

Examples: "truffles picked during the spring are tasty" → partmod(truffles, picked)


INFINITIVAL_MODIFIER

public static final GrammaticalRelation INFINITIVAL_MODIFIER
The "infinitval modifier" grammatical relation. A participial modifier of an NP is an S/VP that serves to modify the meaning of the NP.

Examples: "points to establish are ..." → infmod(points, establish)


ADVERBIAL_MODIFIER

public static final GrammaticalRelation ADVERBIAL_MODIFIER
The "adverbial modifier" grammatical relation. An adverbial modifier of a word is an RB or ADVP that serves to modify the meaning of the word.

Examples: "genetically modified food" → advmod(modified, genetically)


DETERMINER

public static final GrammaticalRelation DETERMINER
The "determiner" grammatical relation. We're treating these as a sort of degenerate NP modifier, for now.

Method Detail

values

public static final GrammaticalRelation[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(GrammaticalRelation c : GrammaticalRelation.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static GrammaticalRelation valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name

getRelatedNodes

public java.util.List<Tree> getRelatedNodes(Tree t)
Given a Tree node t, attempts to return a list of nodes to which node t has this grammatical relation.


isApplicable

public boolean isApplicable(Tree t)
Returns true iff the value of Tree node t matches the sourcePattern for this GrammaticalRelation, indicating that this GrammaticalRelation is one that could hold between Tree node t and some other node.


isAncestor

public boolean isAncestor(GrammaticalRelation gr)

toString

public java.lang.String toString()
Returns short name (abbreviation) for this GrammaticalRelation.

Overrides:
toString in class java.lang.Enum<GrammaticalRelation>

toPrettyString

public java.lang.String toPrettyString()
Returns a String representation of this GrammaticalRelation and the hierarchy below it, with one node per line, indented according to level.

Returns:
String representation of this GrammaticalRelation

main

public static void main(java.lang.String[] args)