|
|||||||||
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 java.util.List<TypedDependency> |
allTypedDependencies
|
protected java.util.Set<Dependency<Label,Label,java.lang.Object>> |
dependencies
|
protected java.util.List<TypedDependency> |
typedDependencies
|
Fields inherited from class edu.stanford.nlp.trees.TreeGraph |
---|
root |
Constructor Summary | |
---|---|
GrammaticalStructure(java.util.List<TypedDependency> projectiveDependencies,
TreeGraphNode root)
|
|
GrammaticalStructure(Tree t,
java.util.Collection<GrammaticalRelation> relations,
HeadFinder hf,
Filter<java.lang.String> puncFilter)
|
|
GrammaticalStructure(Tree t,
java.util.Collection<GrammaticalRelation> relations,
java.util.concurrent.locks.Lock relationsLock,
HeadFinder hf,
Filter<java.lang.String> puncFilter)
Create a new GrammaticalStructure, analyzing the parse tree and populate the GrammaticalStructure with as many labeled grammatical relation arcs as possible. |
Method Summary | |
---|---|
java.util.Collection<TypedDependency> |
allTypedDependencies()
Returns all the typed dependencies of this grammatical structure. |
protected void |
collapseDependencies(java.util.List<TypedDependency> list,
boolean CCprocess)
Destructively modify the Collection<TypedDependency> to collapse
language-dependent transitive dependencies. |
protected void |
collapseDependenciesTree(java.util.List<TypedDependency> list)
Destructively modify the Collection<TypedDependency> to collapse
language-dependent transitive dependencies but keeping a tree structure. |
protected void |
correctDependencies(java.util.Collection<TypedDependency> list)
Destructively modify the TypedDependencyGraph to correct
language-dependent dependencies. |
java.util.Set<Dependency<Label,Label,java.lang.Object>> |
dependencies()
Returns the set of (governor, dependent) dependencies in this GrammaticalStructure . |
java.util.List<java.lang.String> |
getDependencyPath(int nodeIndex,
int rootIndex)
Returns the dependency path as a list of String, from node to root, it is assumed that that root is an ancestor of node |
java.util.Set<TreeGraphNode> |
getDependents(TreeGraphNode t)
Tries to return a Set of leaf (terminal) nodes
which are the s of the given node t . |
static 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 |
static GrammaticalRelation |
getGrammaticalRelation(TreeGraphNode gov,
TreeGraphNode dep)
Get GrammaticalRelation between gov and dep, and null if gov is not the governor of dep |
static java.util.List<GrammaticalRelation> |
getListGrammaticalRelation(TreeGraphNode gov,
TreeGraphNode dep)
Get a list of GrammaticalRelation between gov and dep. |
static TreeGraphNode |
getNodeInRelation(TreeGraphNode t,
GrammaticalRelation r)
|
static java.util.Collection<TypedDependency> |
getRoots(java.util.Collection<TypedDependency> list)
Return a list of TypedDependencies which are not dependent on any node from the list. |
static boolean |
isConnected(java.util.Collection<TypedDependency> list)
Checks if all the typeDependencies are connected |
java.util.Collection<TypedDependency> |
typedDependencies()
Returns the typed dependencies of this grammatical structure. |
java.util.List<TypedDependency> |
typedDependencies(boolean includeExtras)
Returns the typed dependencies of this grammatical structure. |
java.util.List<TypedDependency> |
typedDependenciesCCprocessed()
Get a list of the typed dependencies, including extras like control dependencies, collapsing them and distributing relations across coordination. |
java.util.List<TypedDependency> |
typedDependenciesCCprocessed(boolean includeExtras)
Get the typed dependencies after collapsing them and processing eventual CC complements. |
java.util.Collection<TypedDependency> |
typedDependenciesCollapsed()
Get the typed dependencies after collapsing them. |
java.util.List<TypedDependency> |
typedDependenciesCollapsed(boolean includeExtras)
Get the typed dependencies after collapsing them. |
java.util.Collection<TypedDependency> |
typedDependenciesCollapsedTree()
Get the typed dependencies after mostly collapsing them, but keep a tree structure. |
Methods inherited from class edu.stanford.nlp.trees.TreeGraph |
---|
addNodeToIndexMap, getNodeByIndex, getNodes, main, root, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final java.util.Set<Dependency<Label,Label,java.lang.Object>> dependencies
protected final java.util.List<TypedDependency> typedDependencies
protected final java.util.List<TypedDependency> allTypedDependencies
Constructor Detail |
---|
public GrammaticalStructure(Tree t, java.util.Collection<GrammaticalRelation> relations, java.util.concurrent.locks.Lock relationsLock, HeadFinder hf, Filter<java.lang.String> puncFilter)
t
- A Tree to analyzerelations
- A set of GrammaticalRelations to considerrelationsLock
- Something needed to make this thread-safehf
- A HeadFinder for analysispuncFilter
- A Filter to reject punctuation. To delete punctuation
dependencies, this filter should return false on
punctuation word strings, and true otherwise.
If punctuation dependencies should be kept, you
should pass in a Filters.<String>acceptFilter().public GrammaticalStructure(java.util.List<TypedDependency> projectiveDependencies, TreeGraphNode root)
public GrammaticalStructure(Tree t, java.util.Collection<GrammaticalRelation> relations, HeadFinder hf, Filter<java.lang.String> puncFilter)
Method Detail |
---|
public java.util.Set<Dependency<Label,Label,java.lang.Object>> dependencies()
GrammaticalStructure
.
GrammaticalStructure
.public java.util.Set<TreeGraphNode> 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 static 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 static TreeGraphNode getNodeInRelation(TreeGraphNode t, GrammaticalRelation r)
public GrammaticalRelation getGrammaticalRelation(int govIndex, int depIndex)
public static GrammaticalRelation getGrammaticalRelation(TreeGraphNode gov, TreeGraphNode dep)
public static java.util.List<GrammaticalRelation> getListGrammaticalRelation(TreeGraphNode gov, TreeGraphNode dep)
public java.util.Collection<TypedDependency> typedDependencies()
public java.util.Collection<TypedDependency> allTypedDependencies()
public java.util.List<TypedDependency> typedDependencies(boolean includeExtras)
public java.util.Collection<TypedDependency> typedDependenciesCollapsed()
public java.util.Collection<TypedDependency> typedDependenciesCollapsedTree()
public java.util.List<TypedDependency> typedDependenciesCollapsed(boolean includeExtras)
public java.util.List<TypedDependency> typedDependenciesCCprocessed(boolean includeExtras)
true
.
includeExtras
- If true, the list of typed dependencies
returned may include "extras", such as controlled subject links.
public java.util.List<TypedDependency> typedDependenciesCCprocessed()
protected void collapseDependencies(java.util.List<TypedDependency> list, boolean CCprocess)
Collection<TypedDependency>
to collapse
language-dependent transitive dependencies.
Default is no-op; to be over-ridden in subclasses.
list
- A list of dependencies to process for possible collapsingCCprocess
- apply CC process?protected void collapseDependenciesTree(java.util.List<TypedDependency> list)
Collection<TypedDependency>
to collapse
language-dependent transitive dependencies but keeping a tree structure.
Default is no-op; to be over-ridden in subclasses.
list
- A list of dependencies to process for possible collapsingprotected void correctDependencies(java.util.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.
public java.util.List<java.lang.String> getDependencyPath(int nodeIndex, int rootIndex)
public static boolean isConnected(java.util.Collection<TypedDependency> list)
list
- a list of typedDependencies
public static java.util.Collection<TypedDependency> getRoots(java.util.Collection<TypedDependency> list)
list
- The list of TypedDependencies to check
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |