|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<Tree>
edu.stanford.nlp.trees.Tree
edu.stanford.nlp.trees.ParentalTreeWrapper
public class ParentalTreeWrapper
A wrapper class for a regular tree that looks like a Tree, but adds
parent pointers to the nodes. Calls to parent() or parent(root)
return the cached parent pointer, and other calls are passed
through to the underlying Tree. This is useful in the Tregex
system, where it greatly reduces the time spent searching for
parent nodes.
TODO: only those calls used by the Tregex system get passed along
to the underlying Tree. Other users may want to expand on this.
Field Summary |
---|
Fields inherited from class edu.stanford.nlp.trees.Tree |
---|
DISPLAY_SCORES, EMPTY_TREE_ARRAY |
Constructor Summary | |
---|---|
ParentalTreeWrapper(Tree tree)
|
|
ParentalTreeWrapper(Tree tree,
Tree parent)
|
Method Summary | |
---|---|
Tree[] |
children()
Returns an array of children for the current node. |
Tree |
getBackingTree()
|
Label |
label()
Returns the label associated with the current node, or null if there is no label. |
Tree |
parent()
Return the parent of the tree node. |
Tree |
parent(Tree root)
Return the parent of the tree node. |
TreeFactory |
treeFactory()
Return a TreeFactory that produces trees of the
appropriate type. |
java.lang.String |
value()
Return a String representation of just the "main" value of this label. |
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 |
Constructor Detail |
---|
public ParentalTreeWrapper(Tree tree)
public ParentalTreeWrapper(Tree tree, Tree parent)
Method Detail |
---|
public Tree[] children()
Tree
isLeaf()
returns
true, or this node has a nonzero number of children.
children
in class Tree
Tree.getChildrenAsList()
public TreeFactory treeFactory()
Tree
TreeFactory
that produces trees of the
appropriate type.
treeFactory
in class Tree
public Tree parent()
Tree
null
meaning simply that the implementation doesn't
know how to determine the parent node, rather than there is no
such node.
parent
in class Tree
Tree
node or null
Tree.parent(Tree)
public Tree parent(Tree root)
Tree
root
, and will
correctly find the parent, regardless of whether the concrete
class stores parents. It will only return null
if this
node is the root
node, or if this node is not
contained within the tree rooted at root
.
parent
in class Tree
root
- The root node of the whole Tree
Tree
node if any;
else null
public Tree getBackingTree()
public Label label()
Tree
null
.
label
in interface Labeled
label
in class Tree
public java.lang.String value()
Label
value
in interface Label
value
in class Tree
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |