edu.stanford.nlp.trees
Class EnglishGrammaticalStructure

java.lang.Object
  extended by edu.stanford.nlp.trees.TreeGraph
      extended by edu.stanford.nlp.trees.GrammaticalStructure
          extended by edu.stanford.nlp.trees.EnglishGrammaticalStructure
All Implemented Interfaces:
Serializable

public class EnglishGrammaticalStructure
extends GrammaticalStructure

A GrammaticalStructure for English.

The parser should be run with the "-retainNPTmpSubcategories" option! Caveat emptor! This is a work in progress. Suggestions welcome.

Author:
Bill MacCartney, Marie-Catherine de Marneffe
See Also:
Serialized Form

Field Summary
static String CONJ_MARKER
           
static String DEFAULT_PARSER_FILE
           
 
Fields inherited from class edu.stanford.nlp.trees.GrammaticalStructure
allTypedDependencies, dependencies, typedDependencies
 
Fields inherited from class edu.stanford.nlp.trees.TreeGraph
root
 
Constructor Summary
EnglishGrammaticalStructure(Tree t)
          Construct a new GrammaticalStructure from an existing parse tree.
EnglishGrammaticalStructure(Tree t, Filter<String> puncFilter)
          Construct a new GrammaticalStructure from an existing parse tree.
 
Method Summary
protected  void collapseDependencies(Collection<TypedDependency> list, boolean CCprocess)
          Destructively modifies this TypedDependencyList by collapsing two types of transitive pairs of dependencies: prepositional object dependencies: pobj prep(cat, in) and pobj(in, hat) are collapsed to prep_in(cat, hat) prepositional complement dependencies: pcomp prep(heard, of) and pcomp(of, attacking) are collapsed to prepc_of(heard, attacking) conjunct dependencies cc(investors, and) and conj(investors, regulators) are collapsed to conj_and(investors,regulators) It will also erase possesive dependencies possessive(Montezuma, 's) will be erased For relative clauses, it will collapse referent such as: ref(man, that) and dobj(love, that) are collapsed to dobj(love, man)
protected  GrammaticalRelation conjValue(Object conj)
           
protected  void correctDependencies(Collection<TypedDependency> list)
          Destructively modify the TypedDependencyGraph to correct language-dependent dependencies.
 TreeGraphNode getSubject(TreeGraphNode t)
          Tries to return a node representing the SUBJECT (whether nominal or clausal) of the given node t.
static void main(String[] args)
          Given sentences or trees, output the typed dependencies.

By default, the method outputs the collapsed typed dependencies.

 
Methods inherited from class edu.stanford.nlp.trees.GrammaticalStructure
allTypedDependencies, dependencies, getAllDependents, getDependencyPath, getDependencyPath, getDependents, getDeps, getGovernor, getGrammaticalRelation, getGrammaticalRelation, getListGrammaticalRelation, getNodeInRelation, getRoots, isConnected, toString, typedDependencies, typedDependencies, typedDependenciesCCprocessed, typedDependenciesCollapsed, typedDependenciesCollapsed
 
Methods inherited from class edu.stanford.nlp.trees.TreeGraph
addNodeToIndexMap, getNodeByIndex, getNodes, root
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONJ_MARKER

public static final String CONJ_MARKER
See Also:
Constant Field Values

DEFAULT_PARSER_FILE

public static final String DEFAULT_PARSER_FILE
See Also:
Constant Field Values
Constructor Detail

EnglishGrammaticalStructure

public EnglishGrammaticalStructure(Tree t)
Construct a new GrammaticalStructure from an existing parse tree. The new GrammaticalStructure has the same tree structure and label values as the given tree (but no shared storage). As part of construction, the parse tree is analyzed using definitions from GrammaticalRelation to populate the new GrammaticalStructure with as many labeled grammatical relations as it can.

Parameters:
t - Parse tree to make grammatical structure from

EnglishGrammaticalStructure

public EnglishGrammaticalStructure(Tree t,
                                   Filter<String> puncFilter)
Construct a new GrammaticalStructure from an existing parse tree. The new GrammaticalStructure has the same tree structure and label values as the given tree (but no shared storage). As part of construction, the parse tree is analyzed using definitions from GrammaticalRelation to populate the new GrammaticalStructure with as many labeled grammatical relations as it can.

Parameters:
t - Parse tree to make grammatical structure from
puncFilter - Filter for punctuation words
Method Detail

getSubject

public TreeGraphNode getSubject(TreeGraphNode t)
Tries to return a node representing the SUBJECT (whether nominal or clausal) of the given node t. Probably, node t should represent a clause or verb phrase.

Parameters:
t - a node in this GrammaticalStructure
Returns:
a node which is the subject of node t, or else null

correctDependencies

protected void correctDependencies(Collection<TypedDependency> list)
Description copied from class: GrammaticalStructure
Destructively modify the TypedDependencyGraph to correct language-dependent dependencies. (e.g., nsubjpass in a relative clause)

Default is no-op; to be over-ridden in subclasses.

Overrides:
correctDependencies in class GrammaticalStructure

collapseDependencies

protected void collapseDependencies(Collection<TypedDependency> list,
                                    boolean CCprocess)
Destructively modifies this TypedDependencyList by collapsing two types of transitive pairs of dependencies:
prepositional object dependencies: pobj
prep(cat, in) and pobj(in, hat) are collapsed to prep_in(cat, hat)
prepositional complement dependencies: pcomp
prep(heard, of) and pcomp(of, attacking) are collapsed to prepc_of(heard, attacking)
conjunct dependencies
cc(investors, and) and conj(investors, regulators) are collapsed to conj_and(investors,regulators)
It will also erase possesive dependencies possessive(Montezuma, 's) will be erased For relative clauses, it will collapse referent such as:
ref(man, that) and dobj(love, that) are collapsed to dobj(love, man)

Overrides:
collapseDependencies in class GrammaticalStructure

conjValue

protected GrammaticalRelation conjValue(Object conj)

main

public static void main(String[] args)
Given sentences or trees, output the typed dependencies.

By default, the method outputs the collapsed typed dependencies. The input can be given as plain text (one sentence by line) using the option -sentFile, or as trees using the option -treeFile.

The following options can be used to specify the types of dependencies wanted:
-collapsed collapsed dependencies (by default)
-basic non-collapsed dependencies
-CCprocessed collapsed dependenices and conjunctions processed (dependenices are added for each conjunct)
The -test option is used for debugging: it prints the grammatical structure, as well as the basic, collapsed and CCprocessed dependencies. It also checks the connectivity of the collapsed dependencies. If the collapsed dependencies list doesn't constitute a connected graph, it prints the possible offending nodes (one of them is the real root of the graph).

Usage:
java edu.stanford.nlp.trees.EnglishGrammaticalStructure [-treeFile FILE | -sentFile FILE]
[-collapsed -basic -CCprocessed -test]



Stanford NLP Group