|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.trees.TreeGraph
edu.stanford.nlp.trees.GrammaticalStructure
public abstract class GrammaticalStructure
A GrammaticalStructure
is a
(that is, a tree with additional labeled
arcs between nodes) for representing the grammatical relations in a
parse tree. A new TreeGraph
GrammaticalStructure
is constructed
from an existing parse tree with the help of
, which
defines a hierarchy of grammatical relations, along with
patterns for identifying them in parse trees. The constructor for
GrammaticalRelation
GrammaticalStructure
uses these definitions to
populate the new GrammaticalStructure
with as many
labeled grammatical relations as it can. Once constructed, the new
GrammaticalStructure
can be printed in various
formats, or interrogated using the interface methods in this
class.
EnglishGrammaticalRelations
,
GrammaticalRelation
,
EnglishGrammaticalStructure
,
Serialized FormField Summary | |
---|---|
protected Collection<TypedDependency> |
allTypedDependencies
|
protected Set<Dependency> |
dependencies
|
protected Collection<TypedDependency> |
typedDependencies
|
Fields inherited from class edu.stanford.nlp.trees.TreeGraph |
---|
root |
Constructor Summary | |
---|---|
GrammaticalStructure(Tree t,
Collection<GrammaticalRelation> relations,
HeadFinder hf,
Filter puncFilter)
Create a new GrammaticalStructure, analyzing the parse tree and populate the GrammaticalStructure with as many labeled grammatical relation arcs as possible. |
Method Summary | |
---|---|
Collection<TypedDependency> |
allTypedDependencies()
Returns all the typed dependencies of this grammatical structure. |
protected void |
collapseDependencies(Collection<TypedDependency> list,
boolean CCprocess)
Destructively modify the TypedDependencyList to collapse
language-dependent transitive dependencies. |
protected void |
correctDependencies(Collection<TypedDependency> list)
Destructively modify the TypedDependencyGraph to correct
language-dependent dependencies. |
Set<Dependency> |
dependencies()
Returns the set of (governor, dependent) dependencies in this GrammaticalStructure . |
Map |
getAllDependents(TreeGraphNode node)
returns all the dependencies of a certain node. |
List |
getDependencyPath(int nodeIndex,
int rootIndex)
Returns the dependency path as a list of labels, from node to root, it is assumed that that root is an ancestor of node |
List |
getDependencyPath(TreeGraphNode node,
TreeGraphNode root)
Returns the dependency path as a list of labels, from node to root, it is assumed that that root is an ancestor of node |
Set |
getDependents(TreeGraphNode t)
Tries to return a Set of leaf (terminal) nodes
which are the s of the given node t . |
Collection<TypedDependency> |
getDeps(boolean extra)
The constructor builds a list of typed dependencies using information from a GrammaticalStructure . |
TreeGraphNode |
getGovernor(TreeGraphNode t)
Tries to return a leaf (terminal) node which is the of the given node t . |
GrammaticalRelation |
getGrammaticalRelation(int govIndex,
int depIndex)
Get GrammaticalRelation between gov and dep, and null if gov is not the governor of dep |
GrammaticalRelation |
getGrammaticalRelation(TreeGraphNode gov,
TreeGraphNode dep)
Get GrammaticalRelation between gov and dep, and null if gov is not the governor of dep |
List<GrammaticalRelation> |
getListGrammaticalRelation(TreeGraphNode gov,
TreeGraphNode dep)
Get a list of GrammaticalRelation between gov and dep. |
TreeGraphNode |
getNodeInRelation(TreeGraphNode t,
GrammaticalRelation r)
|
String |
toString()
Return a String representing this treegraph. |
Collection<TypedDependency> |
typedDependencies()
Returns the typed dependencies of this grammatical structure which do not break the tree structure of dependencies |
Collection<TypedDependency> |
typedDependencies(boolean includeExtras)
Returns the typed dependencies of this grammatical structure. |
Collection<TypedDependency> |
typedDependenciesCCprocessed(boolean includeExtras)
Get the typed dependencies after collapsing them and processing eventual CC complements. |
Collection<TypedDependency> |
typedDependenciesCollapsed()
Get the typed dependencies after collapsing them. |
Collection<TypedDependency> |
typedDependenciesCollapsed(boolean includeExtras)
Get the typed dependencies after collapsing them. |
Methods inherited from class edu.stanford.nlp.trees.TreeGraph |
---|
addNodeToIndexMap, getNodeByIndex, getNodes, main, root |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Set<Dependency> dependencies
protected Collection<TypedDependency> typedDependencies
protected Collection<TypedDependency> allTypedDependencies
Constructor Detail |
---|
public GrammaticalStructure(Tree t, Collection<GrammaticalRelation> relations, HeadFinder hf, Filter puncFilter)
relations
- a set of GrammaticalRelations to considert
- a Tree to analyzehf
- a HeadFinder for analysispuncFilter
- a Filter to reject punctuationMethod Detail |
---|
public String toString()
TreeGraph
String
representing this treegraph. By
default, the nodes of the treegraph are printed in Lispy
(parenthesized) format, with one node per line, indented
according to depth.
toString
in class TreeGraph
String
representation of this treegraphpublic Collection<TypedDependency> getDeps(boolean extra)
GrammaticalStructure
.
extra
- If true, the list of typed dependencies will contain extra ones.
If false, the list of typed dependencies will respect the tree structure.public Set<Dependency> dependencies()
GrammaticalStructure
.
public Set getDependents(TreeGraphNode t)
Set
of leaf (terminal) nodes
which are the DEPENDENT
s of the given node t
.
Probably, t
should be a leaf node as well.
t
- a leaf node in this GrammaticalStructure
Set
of nodes which are dependents of
node t
, or else null
public TreeGraphNode getGovernor(TreeGraphNode t)
GOVERNOR
of the given node t
.
Probably, t
should be a leaf node as well.
t
- a leaf node in this GrammaticalStructure
t
, or else null
public TreeGraphNode getNodeInRelation(TreeGraphNode t, GrammaticalRelation r)
public GrammaticalRelation getGrammaticalRelation(int govIndex, int depIndex)
public GrammaticalRelation getGrammaticalRelation(TreeGraphNode gov, TreeGraphNode dep)
public List<GrammaticalRelation> getListGrammaticalRelation(TreeGraphNode gov, TreeGraphNode dep)
public Collection<TypedDependency> typedDependencies()
public Collection<TypedDependency> allTypedDependencies()
public Collection<TypedDependency> typedDependencies(boolean includeExtras)
public Collection<TypedDependency> typedDependenciesCollapsed()
public Collection<TypedDependency> typedDependenciesCollapsed(boolean includeExtras)
public Collection<TypedDependency> typedDependenciesCCprocessed(boolean includeExtras)
protected void collapseDependencies(Collection<TypedDependency> list, boolean CCprocess)
TypedDependencyList
to collapse
language-dependent transitive dependencies.
Default is no-op; to be over-ridden in subclasses.
list
- protected void correctDependencies(Collection<TypedDependency> list)
TypedDependencyGraph
to correct
language-dependent dependencies. (e.g., nsubjpass in a relative clause)
Default is no-op; to be over-ridden in subclasses.
list
- public List getDependencyPath(int nodeIndex, int rootIndex)
nodeIndex
- rootIndex
-
public List getDependencyPath(TreeGraphNode node, TreeGraphNode root)
node
- root
-
public Map getAllDependents(TreeGraphNode node)
node
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |