|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection
edu.stanford.nlp.trees.Tree
edu.stanford.nlp.trees.TreeGraphNode
public class TreeGraphNode
A "treegraph" is a tree with additional directed, labeled arcs
between arbitrary pairs of nodes. (So, it's a graph with a tree
skeleton.) A TreeGraphNode represents any node in a
treegraph. The additional labeled arcs are represented by using
labels at each node, which
contain MapLabelMaps from arc label strings to
Sets of TreeGraphNodes. Each
TreeGraphNode should contain a reference to a object, which is a container for
the complete treegraph structure.TreeGraph
TreeGraph,
Serialized Form| Field Summary | |
|---|---|
protected TreeGraphNode[] |
children
Children of this node. |
protected MapLabel |
label
Label for this node. |
protected TreeGraphNode |
parent
Parent of this node. |
protected TreeGraph |
tg
The of which this
node is part. |
protected static TreeGraphNode[] |
ZERO_TGN_CHILDREN
A leaf node should have a zero-length array for its children. |
| Fields inherited from class edu.stanford.nlp.trees.Tree |
|---|
ZEROCHILDREN |
| Constructor Summary | |
|---|---|
TreeGraphNode()
Create a new empty TreeGraphNode. |
|
TreeGraphNode(Label label)
Create a new TreeGraphNode with the supplied
label. |
|
TreeGraphNode(Label label,
List children)
Create a new TreeGraphNode with the supplied
label and list of child nodes. |
|
TreeGraphNode(Tree t,
TreeGraphNode parent)
Create a new TreeGraphNode having the same tree
structure and label values as an existing tree (but no shared
storage). |
|
| Method Summary | |
|---|---|
boolean |
addArc(Object arcLabel,
TreeGraphNode node)
Add a labeled arc from this node to the argument node. |
Set |
arcLabelsToNode(TreeGraphNode destNode)
Finds all arcs between this node and destNode,
and returns the Set of Objects which
label those arcs. |
Object |
arcLabelToNode(TreeGraphNode destNode)
Returns the label of a single arc between this node and destNode,
or null if no such arc exists. |
Tree[] |
children()
Returns an array of the children of this node. |
Set |
dependencies(Filter f,
HeadFinder hf)
Return a set of node-node dependencies, represented as Dependency objects, for the Tree. |
boolean |
equals(Object o)
Implements equality for TreeGraphNodes. |
static TreeFactory |
factory()
Return a TreeFactory that produces trees of type
TreeGraphNode. |
static TreeFactory |
factory(LabelFactory lf)
Return a TreeFactory that produces trees of type
TreeGraphNode, with the Label made
by the supplied LabelFactory. |
TreeGraphNode |
followArcToNode(Object arcLabel)
Returns a single TreeGraphNode to which there
exists an arc bearing the specified label from this node, or
null if no such node exists. |
Set |
followArcToSet(Object arcLabel)
Returns the Set of TreeGraphNodes to
which there exist arcs bearing the specified label from this
node, or null if no such nodes exist. |
TreeGraphNode |
headTagNode()
Return the node containing the head tag for this node (or null if none), as recorded in this node's . |
TreeGraphNode |
headWordNode()
Return the node containing the head word for this node (or null if none), as recorded in this node's . |
TreeGraphNode |
highestNodeWithSameHead()
|
protected int |
index()
Get the index for the current node. |
protected void |
indexNodes()
Assign sequential integer indices (starting with 0) to all nodes of the subtree rooted at this TreeGraphNode. |
Label |
label()
Returns the label associated with the current node, or null if there is no label. |
static void |
main(String[] args)
Just for testing. |
Tree |
parent()
Get the parent for the current node. |
void |
percolateHeads(HeadFinder hf)
Uses the specified
to determine the heads for this node and all its descendants,
and to store references to the head word node and head tag node
in this node's and the
MapLabels of all its descendants. |
void |
setChildren(Tree[] children)
Sets the children of this TreeGraphNode. |
protected void |
setIndex(int index)
Set the index for the current node. |
void |
setLabel(MapLabel label)
Sets the label associated with the current node. |
void |
setParent(TreeGraphNode parent)
Set the parent for the current node. |
protected void |
setTreeGraph(TreeGraph tg)
Set pointer to the TreeGraph of which this node
is a part. |
String |
toOneLineString()
Returns a String representation of this node and
its subtree as a one-line parenthesized list. |
String |
toPrettyString(int indentLevel)
Returns a String representation of this node and
its subtree with one node per line, indented according to
indentLevel. |
String |
toString()
Converts parse tree to string in Penn Treebank format. |
TreeFactory |
treeFactory()
Returns a TreeFactory that produces
TreeGraphNodes. |
protected TreeGraph |
treeGraph()
Get the TreeGraph of which this node is a
part. |
| Methods inherited from class java.util.AbstractCollection |
|---|
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected MapLabel label
protected TreeGraphNode parent
protected TreeGraphNode[] children
protected TreeGraph tg
TreeGraph of which this
node is part.
protected static final TreeGraphNode[] ZERO_TGN_CHILDREN
| Constructor Detail |
|---|
public TreeGraphNode()
TreeGraphNode.
public TreeGraphNode(Label label)
TreeGraphNode with the supplied
label.
label - the label for this node.
public TreeGraphNode(Label label,
List children)
TreeGraphNode with the supplied
label and list of child nodes.
label - the label for this node.children - the list of child TreeGraphNodes
for this node.
public TreeGraphNode(Tree t,
TreeGraphNode parent)
TreeGraphNode having the same tree
structure and label values as an existing tree (but no shared
storage). Operates recursively to construct an entire
subtree.
t - the tree to copyparent - the parent node| Method Detail |
|---|
public boolean equals(Object o)
TreeGraphNodes. Unlike
Trees, TreeGraphNodes should be
considered equal only if they are ==.
equals in interface Collectionequals in class Treeo - The object to compare with
public Label label()
label in interface Labeledlabel in class Treepublic void setLabel(MapLabel label)
label - the new label to use.protected int index()
protected void setIndex(int index)
protected void indexNodes()
TreeGraphNode. The leaves are indexed first,
from left to right. Then the internal nodes are indexed,
using a pre-order tree traversal.
public Tree parent()
parent in class TreeTree node or nullTree.parent(Tree)public void setParent(TreeGraphNode parent)
public Tree[] children()
children in class TreeTree.getChildrenAsList()public void setChildren(Tree[] children)
TreeGraphNode. If
given null, this method sets
the node's children to the canonical zero-length Tree[] array.
setChildren in class Treechildren - an array of child treesTree.setChildren(List)protected TreeGraph treeGraph()
TreeGraph of which this node is a
part.
protected void setTreeGraph(TreeGraph tg)
TreeGraph of which this node
is a part. Operates recursively to set pointer for all
descendants too.
public boolean addArc(Object arcLabel,
TreeGraphNode node)
arcLabel - the Object with which the new arc
is to be labeled.node - the TreeGraphNode to which the new
arc should point.
true iff the arc did not already exist.public Set followArcToSet(Object arcLabel)
Set of TreeGraphNodes to
which there exist arcs bearing the specified label from this
node, or null if no such nodes exist.
arcLabel - the Object which labels the
arc(s) to be followed.
Set containing only and all the
TreeGraphNodes to which there exist arcs bearing
the specified label from this node.public TreeGraphNode followArcToNode(Object arcLabel)
TreeGraphNode to which there
exists an arc bearing the specified label from this node, or
null if no such node exists. If more than one
such node exists, this method will return an arbitrary node
from among them; if this is a possibility, you might want to
use followArcToSet instead.
arcLabel - a Object containing the label of
the arc(s) to be followed
TreeGraphNodes to which there exists an
arc bearing the specified label from this nodepublic Set arcLabelsToNode(TreeGraphNode destNode)
destNode,
and returns the Set of Objects which
label those arcs. If no such arcs exist, returns an empty
Set.
destNode - the destination node
Set of Objects which
label arcs between this node and destNodepublic Object arcLabelToNode(TreeGraphNode destNode)
destNode,
or null if no such arc exists. If more than one
such arc exists, this method will return an arbitrary arc label
from among them; if this is a possibility, you might want to
use arcLabelsToNode instead.
destNode - the destination node
Set of Objects which
label arcs between this node and destNodepublic void percolateHeads(HeadFinder hf)
HeadFinder
to determine the heads for this node and all its descendants,
and to store references to the head word node and head tag node
in this node's MapLabel and the
MapLabels of all its descendants.Note that, in contrast to
Tree.percolateHeads(), which assumes CategoryWordTag labels and therefore stores head
words and head tags merely as Strings, this
method stores references to the actual nodes. This mitigates
potential problems in sentences which contain the same word
more than once.
percolateHeads in class Treehf - The headfinding algorithm to use
public Set dependencies(Filter f,
HeadFinder hf)
dependencies in class Treehf - The HeadFinder to use to identify the head of constituents.
If this is null, then nodes are assumed to already
be marked with their heads.f - Dependencies are excluded for which the Dependency is not
accepted by the Filter
Dependency)public TreeGraphNode headWordNode()
null if none), as recorded in this node's MapLabel. (In contrast to CategoryWordTag, we store head words and head
tags as references to nodes, not merely as
Strings.)
public TreeGraphNode headTagNode()
null if none), as recorded in this node's MapLabel. (In contrast to CategoryWordTag, we store head words and head
tags as references to nodes, not merely as
Strings.)
public TreeGraphNode highestNodeWithSameHead()
public TreeFactory treeFactory()
TreeFactory that produces
TreeGraphNodes. The Label of
this is examined, and providing it is not
null, a LabelFactory which will
produce that kind of Label is supplied to the
TreeFactory. If the Label is
null, a MapLabelFactory will be used. The factories
returned on different calls are different: a new one is
allocated each time.
treeFactory in class Treepublic static TreeFactory factory()
TreeFactory that produces trees of type
TreeGraphNode. The factory returned is always
the same one (a singleton).
public static TreeFactory factory(LabelFactory lf)
TreeFactory that produces trees of type
TreeGraphNode, with the Label made
by the supplied LabelFactory. The factory
returned is a different one each time.
lf - The LabelFactory to use
public String toPrettyString(int indentLevel)
String representation of this node and
its subtree with one node per line, indented according to
indentLevel.
indentLevel - how many levels to indent (0 for root node)
String representation of this subtreepublic String toOneLineString()
String representation of this node and
its subtree as a one-line parenthesized list.
String representation of this subtreepublic String toString()
TreeStringBuffer
through it all.
toString in interface LabeltoString in class Treepublic static void main(String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||