|
|||||||||
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
public abstract class Tree
The abstract class Tree
is used to collect all of the
tree types, and acts as a generic composite type. This is the
standard implementation of inheritance-based polymorphism. Trees,
like standard containers, are not parametrized in any way by the
type of object in the data
field. All
Tree
objects support accessors for their children (a
Tree[]
), their data (a Label
), and their
score (a double
). However, different concrete
implementations may or may not include the latter two, in which
case a default value is returned. The class Tree defines no data
fields. The two abstract methods that must be implemented are:
children()
, and treeFactory()
. Note
that setChildren(Tree[])
is now an optional
operation, whereas it was previously was required to be
implemented. There is now support for finding the parent of a
tree. This may be done by search from a tree root, or via a
directly stored parent. The Tree
class now
implements the Collection
interface: in terms of
this, each node of the tree is an element of the
collection; hence one can explore the tree by using the methods of
this interface. A Tree
is regarded as a read-only
Collection
(even though the Tree
class
has various methods that modify trees). Moreover, the
implementation is not thread-safe: no attempt is made to
detect and report concurrent modifications.
Field Summary | |
---|---|
protected static Tree[] |
ZEROCHILDREN
A leaf node should have a zero-length array for its children. |
Constructor Summary | |
---|---|
Tree()
|
Method Summary | |
---|---|
void |
addChild(int i,
Tree t)
Adds the tree t at the index position among the daughters. |
void |
addChild(Tree t)
Adds the tree t at the last index position among the daughters. |
Tree |
ancestor(int height,
Tree root)
Return the ancestor tree node height nodes up from the current node. |
boolean |
cCommands(Tree t1,
Tree t2)
Given nodes t1 and t2 which are
dominated by this node, returns true iff
t1 c-commands t2 . |
abstract Tree[] |
children()
Returns an array of children for the current node. |
Set |
constituents()
Returns the Constituents generated by the parse tree. |
Set |
constituents(ConstituentFactory cf)
Returns the Constituents generated by the parse tree. |
Tree |
deepCopy()
Create a deep copy of the tree. |
Tree |
deepCopy(TreeFactory tf)
Create a deep copy of the tree. |
Tree |
deeperCopy()
Same as deepCopy but makes a copy of the labels as well. |
Tree |
deeperCopy(TreeFactory tf)
Same as deepCopy but will copy the labels over as well. |
Set<Dependency> |
dependencies()
Return a set of Word-Word dependencies, represented as Dependency objects, for the Tree. |
Set<Dependency> |
dependencies(Filter f)
Return a set of Word-Word dependencies, represented as Dependency objects, for the Tree. |
Set<Dependency> |
dependencies(Filter f,
HeadFinder hf)
Return a set of Word-Word dependencies, represented as Dependency objects, for the Tree. |
Set<Dependency> |
dependencies(HeadFinder hf)
Return a set of Word-Word dependencies, represented as Dependency objects for the Tree. |
int |
depth()
Finds the depth of the tree. |
boolean |
dominates(Tree t)
returns true if this dominates the Tree passed in
as an argument. |
List<Tree> |
dominationPath(Tree t)
returns the path of nodes leading down to a dominated node, including this and the dominated node itself. |
boolean |
equals(Object o)
Implements equality for Tree's. |
Tree |
firstChild()
Returns the first child of a tree, or null if none. |
Tree |
flatten()
Return a flattened version of a tree. |
Tree |
flatten(TreeFactory tf)
Return a flattened version of a tree. |
Tree |
getChild(int i)
Return the child at some daughter index. |
List<Tree> |
getChildrenAsList()
Returns an array of children for the current node. |
List<Tree> |
getLeaves()
Gets the leaves of the tree. |
List<Tree> |
getLeaves(List<Tree> list)
Gets the leaves of the tree. |
IntPair |
getSpan()
|
int |
hashCode()
Implements a hashCode for Tree's. |
Tree |
headPreTerminal(HeadFinder hf)
Returns the preterminal tree that is the head of the tree. |
Tree |
headTerminal(HeadFinder hf)
Returns the tree leaf that is the head of the tree. |
void |
indentedListPrint()
Indented list printing of a tree. |
void |
indentedListPrint(PrintWriter pw,
boolean printScores)
Indented list printing of a tree. |
int |
indexOf(Tree tree)
Returns the position of a Tree in the children list, if present, or -1 if it is not present. |
void |
insertDtr(Tree dtr,
int position)
insert dtr after position existing
daughters in this . |
boolean |
isLeaf()
Says whether a node is a leaf. |
boolean |
isPhrasal()
Return whether this node is a phrasal node or not. |
boolean |
isPrePreTerminal()
Return whether all the children of this node are preterminals or not. |
boolean |
isPreTerminal()
Return whether this node is a preterminal or not. |
boolean |
isUnaryRewrite()
Says whether the current node has only one child. |
Iterator |
iterator()
Returns an iterator over the nodes of the tree. |
Tree |
joinNode(Tree t1,
Tree t2)
Given nodes t1 and t2 which are
dominated by this node, returns their "join node": the node
j such that j dominates both
t1 and t2 , and no other node which
also dominates both t1 and t2
dominates j . |
Label |
label()
Returns the label associated with the current node, or null if there is no label. |
LabelFactory |
labelFactory()
Returns a factory that makes labels of the same type as this one. |
Collection |
labels()
Get the set of all node and leaf Label s,
null or otherwise, contained in the tree. |
Tree |
lastChild()
Returns the last child of a tree, or null if none. |
int |
leftCharEdge(Tree node)
Returns the positional index of the left edge of node within the tree, as measured by characters. |
Tree |
localTree()
Returns a new Tree that represents the local Tree at a certain node. |
String |
nodeString()
|
int |
numChildren()
Says how many children a tree node has in its local tree. |
Tree |
parent()
Return the parent of the tree node. |
Tree |
parent(Tree root)
Return the parent of the tree node. |
List |
pathNodeToNode(Tree t1,
Tree t2)
Given nodes t1 and t2 which are
dominated by this node, returns a list of all the nodes on the
path from t1 to t2, inclusive, or null if none found. |
void |
pennPrint()
Print the tree as done in Penn Treebank merged files. |
void |
pennPrint(PrintStream ps)
Print the tree as done in Penn Treebank merged files. |
void |
pennPrint(PrintWriter pw)
Print the tree as done in Penn Treebank merged files. |
String |
pennString()
Calls pennPrint() and saves output to a String |
void |
percolateHeads(HeadFinder hf)
Finds the heads of the tree. |
List<Label> |
preTerminalYield()
Gets the preterminal yield (i.e., tags) of the tree. |
List<Label> |
preTerminalYield(List<Label> y)
Gets the preterminal yield (i.e., tags) of the tree. |
void |
printLocalTree()
|
void |
printLocalTree(PrintWriter pw)
|
Tree |
prune(Filter filter)
Creates a deep copy of the tree, where all nodes that the filter does not accept and all children of such nodes are pruned. |
Tree |
prune(Filter filter,
TreeFactory tf)
Creates a deep copy of the tree, where all nodes that the filter does not accept and all children of such nodes are pruned. |
Tree |
removeChild(int i)
Destructively removes the child at some daughter index and returns it. |
int |
rightCharEdge(Tree node)
Returns the positional index of the right edge of node within the tree, as measured by characters. |
double |
score()
Returns the score associated with the current node, or NaN if there is no score. |
Tree |
setChild(int i,
Tree t)
Replaces the i th child of this with the tree t. |
void |
setChildren(List childTreesList)
Set the children of this tree node to the given list. |
void |
setChildren(Tree[] children)
Set the children of this node to be the children given in the array. |
void |
setFromString(String labelStr)
Set the contents of this label to this String
representing the
complete contents of the label. |
void |
setLabel(Label label)
Sets the label associated with the current node, if there is one. |
void |
setLabels(Collection c)
Sets the labels associated with this object. |
void |
setScore(double score)
Sets the score associated with the current node, if there is one. |
void |
setSpans()
|
void |
setValue(String value)
Set the value for the label (if one is stored). |
List<Tree> |
siblings(Tree root)
Returns the siblings of this Tree node. |
int |
size()
Returns the number of nodes the tree contains. |
Tree |
spliceOut(Filter nodeFilter)
Creates a (partial) deep copy of the tree, where all nodes that the filter does not accept are spliced out. |
Tree |
spliceOut(Filter nodeFilter,
TreeFactory tf)
Creates a (partial) deep copy of the tree, where all nodes that the filter does not accept are spliced out. |
List<Tree> |
subTreeList()
Get the list of all subtrees inside the tree by returning a tree rooted at each node. |
Set<Tree> |
subTrees()
Get the set of all subtrees inside the tree by returning a tree rooted at each node. |
Collection<Tree> |
subTrees(Collection<Tree> n)
Add the set of all subtrees inside a tree (including the tree itself) to the given Collection . |
Set<Dependency> |
taggedDependencies()
Return a Set of TaggedWord-TaggedWord dependencies, represented as Dependency objects, for the Tree. |
Set<Dependency> |
taggedDependencies(Filter f)
Return a set of TaggedWord-TaggedWord dependencies, represented as Dependency objects, for the Tree. |
Set<Dependency> |
taggedDependencies(Filter f,
HeadFinder hf)
Return a set of TaggedWord-TaggedWord dependencies, represented as Dependency objects, for the Tree. |
Set<Dependency> |
taggedDependencies(HeadFinder hf)
Return a set of TaggedWord-TaggedWord dependencies, represented as Dependency objects for the Tree. |
Sentence |
taggedYield()
Gets the tagged yield of the tree. |
List |
taggedYield(List ty)
Gets the tagged yield of the tree -- that is, get the preterminals as well as the terminals. |
String |
toString()
Converts parse tree to string in Penn Treebank format. |
StringBuffer |
toStringBuffer(StringBuffer sb)
Appends the printed form of a parse tree (as a bracketed String) to a StringBuffer . |
Tree |
transform(TreeTransformer transformer)
Create a transformed Tree. |
Tree |
transform(TreeTransformer transformer,
TreeFactory tf)
Create a transformed Tree. |
abstract TreeFactory |
treeFactory()
Return a TreeFactory that produces trees of the
appropriate type. |
List<TypedDependency> |
typedDependencies()
Return a list of English typed dependencies, as identified and labelled by the GrammaticalRelation class. |
List<TypedDependency> |
typedDependenciesCollapsed()
Return a list of English collapsed typed dependencies, as identified and labelled by the GrammaticalRelation class. |
List<TypedDependency> |
typedDependenciesCollapsed(Filter<TypedDependency> f)
Return a list of English collapsed typed dependencies, as identified and labelled by the GrammaticalRelation class. |
Tree |
upperMostUnary(Tree root)
In case this node is the only child of its parent, trace up the chain of unaries, and return the uppermost node of the chain (the node whose parent has multiple children, or the node that is the root of the tree |
String |
value()
Return a String representation of just the "main" value of this label. |
static Tree |
valueOf(String str)
This gives you a tree from a String representation (as a bracketed Tree, of the kind produced by toString() ,
pennPrint() , or as in the Penn Treebank). |
static Tree |
valueOf(String str,
TreeReaderFactory trf)
This gives you a tree from a String representation (as a bracketed Tree, of the kind produced by toString() ,
pennPrint() , or as in the Penn Treebank. |
Sentence |
yield()
Gets the yield of the tree. |
List |
yield(List y)
Gets the yield of the tree. |
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 static final Tree[] ZEROCHILDREN
Constructor Detail |
---|
public Tree()
Method Detail |
---|
public boolean isLeaf()
Tree
. Being a leaf is defined as having no
children. This must be implemented as returning a zero-length
Tree[] array for children(). This is the preferred
alternative to running meta checks on types, as it works
independent of Tree implementation.
public int numChildren()
Tree
. Being a leaf is defined
as having no children.
public boolean isUnaryRewrite()
Tree
.
public boolean isPreTerminal()
public boolean isPrePreTerminal()
public boolean isPhrasal()
true
if the node is phrasal;
false
otherwisepublic boolean equals(Object o)
equals
in interface Collection
equals
in class Object
o
- The object to compare with
public int hashCode()
hashCode
in interface Collection
hashCode
in class Object
public int indexOf(Tree tree)
equals()
.
tree
- The tree to look for in children list
public abstract Tree[] children()
isLeaf()
returns
true, or this node has a nonzero number of children.
getChildrenAsList()
public List<Tree> getChildrenAsList()
List
of size 0 will be
returned.
public void setChildren(Tree[] children)
ZEROCHILDREN
canonical zero-length Tree[] array
to represent zero children, but it is not required that
leaf nodes use this particular zero-length array to represent
a leaf node.
children
- The array of children, each a Tree
setChildren(List)
public void setChildren(List childTreesList)
Tree
class by
converting the List
into a tree array and calling
the array-based method. Subclasses which use a
List
-based representation of tree children should
override this method. This implementation allows the case
that the List
is null
: it yields a
node with no children (represented by a canonical zero-length
children() array).
childTreesList
- list of trees to become childrensetChildren(Tree[])
public Label label()
null
.
label
in interface Labeled
public void setLabel(Label label)
setLabel
in interface Labeled
label
- The labelpublic double score()
score
in interface Scored
public void setScore(double score)
score
- The scorepublic Tree firstChild()
null
if none.
public Tree lastChild()
null
if none.
public Tree upperMostUnary(Tree root)
root
- The root of the tree that contains this subtree
public void setSpans()
public IntPair getSpan()
public Set constituents()
SimpleConstituent
public Set constituents(ConstituentFactory cf)
cf
- ConstituentFactory used to build the Constituent objects
HashSet
public Tree localTree()
public StringBuffer toStringBuffer(StringBuffer sb)
StringBuffer
.
The implementation of this may be more efficient than for
toString()
on complex trees.
sb
- The StringBuffer to append to
StringBuffer
public String toString()
StringBuffer
through it all.
toString
in interface Label
toString
in class AbstractCollection
public void printLocalTree()
public void printLocalTree(PrintWriter pw)
public void indentedListPrint()
public void indentedListPrint(PrintWriter pw, boolean printScores)
pw
- The PrintWriter to print the tree topublic String nodeString()
public void pennPrint(PrintWriter pw)
pw
- The tree is printed to this PrintWriter
public void pennPrint(PrintStream ps)
ps
- The tree is printed to this PrintStream
public String pennString()
pennPrint()
and saves output to a String
public void pennPrint()
System.out
. The basic deviation
from a bracketed indented tree is to in general
collapse the printing of adjacent preterminals onto one line of
tags and words. Additional complexities are that conjunctions
(tag CC) are not collapsed in this way, and that the unlabeled
outer brackets are collapsed onto the same line as the next
bracket down.
public int depth()
public Tree headTerminal(HeadFinder hf)
hf
- The headfinding algorithm to use
null
public Tree headPreTerminal(HeadFinder hf)
isPreTerminal()
for
the definition of a preterminal node. Beware that some tree nodes may
have no preterminal head.
hf
- The headfinding algorithm to use
null
IllegalArgumentException
- if called on a leaf nodepublic void percolateHeads(HeadFinder hf)
hf
- The headfinding algorithm to usepublic Set<Dependency> dependencies()
public Set<Dependency> dependencies(Filter f)
f
- Dependencies are excluded for which the Dependency is not
accepted by the Filter
public Set<Dependency> dependencies(HeadFinder hf)
hf
- The HeadFinder to use to identify the head of constituents
Dependency
)public Set<Dependency> dependencies(Filter f, HeadFinder hf)
f
- Dependencies are excluded for which the Dependency is not
accepted by the Filterhf
- 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.
Dependency
)public Set<Dependency> taggedDependencies()
public Set<Dependency> taggedDependencies(Filter f)
Implementation note: It would be nice to generalize this with dependencies() to use a LabelFactory, but it seems impossible with the current setup.
f
- Dependencies are excluded for which the Dependency is not
accepted by the Filter
public Set<Dependency> taggedDependencies(HeadFinder hf)
hf
- The HeadFinder to use to identify the head of constituents
Dependency
)public Set<Dependency> taggedDependencies(Filter f, HeadFinder hf)
f
- Dependencies are excluded for which the Dependency is not
accepted by the Filterhf
- 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.
Dependency
)public List<TypedDependency> typedDependencies()
GrammaticalRelation
class.
public List<TypedDependency> typedDependenciesCollapsed()
GrammaticalRelation
class.
These dependencies assume the tree is in English.
public List<TypedDependency> typedDependenciesCollapsed(Filter<TypedDependency> f)
GrammaticalRelation
class.
These dependencies assume the tree is in English.
f
- A filter to exclude certain dependencies
public Sentence yield()
Label
of all leaf nodes
is returned
as a list ordered by the natural left to right order of the
leaves. Null values, if any, are inserted into the list like any
other value.
List
of the data in the tree's leaves.public List yield(List y)
Label
of all leaf nodes
is returned
as a list ordered by the natural left to right order of the
leaves. Null values, if any, are inserted into the list like any
other value. This has been rewritten to thread, so only one List
is used.
y
- The list in which the yield of the tree will be placed.
Normally, this will be empty when the routine is called, but
if not, the new yield is added to the end of the list.
List
of the data in the tree's leaves.public Sentence taggedYield()
Label
of all leaf nodes is returned
as a list ordered by the natural left to right order of the
leaves. Null values, if any, are inserted into the list like any
other value.
List
of the data in the tree's leaves.public List taggedYield(List ty)
Label
of all leaf nodes
is returned
as a list ordered by the natural left to right order of the
leaves. Null values, if any, are inserted into the list like any
other value. This has been rewritten to thread, so only one List
is used.
ty
- The list in which the tagged yield of the tree will be
placed. Normally, this will be empty when the routine is called,
but if not, the new yield is added to the end of the list.
List
of the data in the tree's leaves.public List<Label> preTerminalYield()
List
of the data in the tree's pre-leaves.public List<Label> preTerminalYield(List<Label> y)
y
- The list in which the preterminals of the tree will be
placed. Normally, this will be empty when the routine is called,
but if not, the new yield is added to the end of the list.
List
of the data in the tree's pre-leaves.public List<Tree> getLeaves()
List
of the leaves.public List<Tree> getLeaves(List<Tree> list)
list
- The list in which the leaves of the tree will be
placed. Normally, this will be empty when the routine is called,
but if not, the new yield is added to the end of the list.
List
of the leaves.public Collection labels()
Label
s,
null or otherwise, contained in the tree.
labels
in interface Labeled
Collection
(actually, Set) of all values
in the tree.public void setLabels(Collection c)
Labeled
setLabels
in interface Labeled
c
- The set of Label valuespublic Tree flatten()
label()
equal() to
the label()
of its parent, and all its children will
then be promoted to become children of the parent (in the same
position in the sequence of daughters.
public Tree flatten(TreeFactory tf)
label()
equal() to
the label()
of its parent, and all its children will
then be promoted to become children of the parent (in the same
position in the sequence of daughters. Note: In the current implementation, the tree structure is mainly duplicated, but the links between preterminals and terminals aren't.
tf
- TreeFactory used to create tree structure for flattened tree
public Set<Tree> subTrees()
Set
of all subtrees in the tree.public List<Tree> subTreeList()
List
of all subtrees in the tree.public Collection<Tree> subTrees(Collection<Tree> n)
Collection
.
n
- A collection of nodes to which the subtrees will be added
public Tree deeperCopy()
public Tree deeperCopy(TreeFactory tf)
tf
- The TreeFactory used to make all nodes in the copied
tree structure
public Tree deepCopy()
TreeFactory
that will
produce a Tree
like the input one.
public Tree deepCopy(TreeFactory tf)
TreeFactory
, this
method can be used to change the type of a Tree
.
tf
- The TreeFactory
to be used for creating
the returned Tree
public Tree transform(TreeTransformer transformer)
TreeTransformer
is called
on each node. It returns some Tree
. The transformed
tree has a new tree structure (i.e., a "deep copy" is done), but it
will usually share its labels with the original tree.
transformer
- The function that transforms tree nodes or subtrees
Tree
public Tree transform(TreeTransformer transformer, TreeFactory tf)
TreeTransformer
is called
on each node. It returns some Tree
. The transformed
tree has a new tree structure (i.e., a "deep copy" is done), but it
will usually share its labels with the original tree.
transformer
- The function that transforms tree nodes or subtreestf
- The TreeFactory
which will be used for creating
new nodes for the returned Tree
Tree
public Tree spliceOut(Filter nodeFilter)
nodeFilter
- a Filter method which returns true to mean
keep this node, false to mean delete it
public Tree spliceOut(Filter nodeFilter, TreeFactory tf)
Filter
returns false
are removed from the Tree
, but those nodes' children
are kept (assuming they pass the Filter
, and they are
added in the appropriate left-to-right ordering as new children of
the parent node. If the root node is deleted, so that the result
would not be a tree (that is, it's a forest), an empty root node is
generated. If nothing is accepted, null
is returned.
nodeFilter
- a Filter method which returns true to mean
keep this node, false to mean delete ittf
- A TreeFactory
for making new trees. Used if
the root node is deleted.
public Tree prune(Filter filter)
Filter
can assume
that it will not be called with a null
argument.
For example, the following code excises all PP nodes from a Tree:
Filter
filter
- the filter to be apply
public Tree prune(Filter filter, TreeFactory tf)
Filter
can assume
that it will not be called with a null
argument.
filter
- the filter to be applytf
- the TreeFactory to be used to make new Tree nodes if needed
null
if the root node of the tree is filteredpublic abstract TreeFactory treeFactory()
TreeFactory
that produces trees of the
appropriate type.
public Tree parent()
null
meaning simply that the implementation doesn't
know how to determine the parent node, rather than there is no
such node.
Tree
node or null
parent(Tree)
public Tree parent(Tree root)
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
.
root
- The root node of the whole Tree
Tree
node if any;
else null
public int size()
size()
function required by the
Collections
interface. The size of the tree is the
number of nodes it contains (of all types, including the leaf nodes
and the root).
size
in interface Collection
size
in class AbstractCollection
depth()
public Tree ancestor(int height, Tree root)
height
nodes up from the current node.
height
- How many nodes up to go. A parameter of 0 means return
this node, 1 means to return the parent node and so on.
height
. It returns null
if it does not exist or the tree implementation does not keep track
of parentspublic Iterator iterator()
iterator()
method required by the
Collections
interface. It does a preorder
(children after node) traversal of the tree. (A possible
extension to the class at some point would be to allow different
traversal orderings via variant iterators.)
iterator
in interface Iterable
iterator
in interface Collection
iterator
in class AbstractCollection
public static Tree valueOf(String str) throws IOException
toString()
,
pennPrint()
, or as in the Penn Treebank).
It's not the most efficient thing to do for heavy duty usage.
The Tree returned is created by a
StringLabeledScoredTreeReaderFactory.
str
- The tree as a bracketed list in a String.
IOException
- If Tree format is not validpublic static Tree valueOf(String str, TreeReaderFactory trf) throws IOException
toString()
,
pennPrint()
, or as in the Penn Treebank.
It's not the most efficient thing to do for heavy duty usage.
str
- The tree as a bracketed list in a String.
IOException
- If Tree format is not validpublic Tree getChild(int i)
i
- The daughter index
public Tree removeChild(int i)
ArrayIndexOutOfBoundsException
if
the daughter index is too big for the list of daughters.
i
- The daughter index
public void addChild(int i, Tree t)
ArrayIndexOutOfBoundsException
if
the the daughter index is too big for the list of daughters.
i
- the index position at which to add the new daughtert
- the new daughterpublic void addChild(Tree t)
t
- the new daughterpublic Tree setChild(int i, Tree t)
i
th child of this
with the tree t. Note
that this method will throw an ArrayIndexOutOfBoundsException
if
the the child index is too big for the list of children.
i
- The index position at which to replace the childt
- The new child
public boolean dominates(Tree t)
this
dominates the Tree passed in
as an argument.
public List<Tree> dominationPath(Tree t)
this
and the dominated node itself.
Returns null if t is not dominated by this
. Object
equality (==) is the relevant criterion.
public List pathNodeToNode(Tree t1, Tree t2)
t1
and t2
which are
dominated by this node, returns a list of all the nodes on the
path from t1 to t2, inclusive, or null if none found.
public Tree joinNode(Tree t1, Tree t2)
t1
and t2
which are
dominated by this node, returns their "join node": the node
j
such that j
dominates both
t1
and t2
, and no other node which
also dominates both t1
and t2
dominates j
. (Remember that domination is defined
such that every node dominates itself.) Returns
null
if no such node can be found.
public boolean cCommands(Tree t1, Tree t2)
t1
and t2
which are
dominated by this node, returns true
iff
t1
c-commands t2
. (A node c-commands
its sister(s) and any nodes below its sister(s).)
public List<Tree> siblings(Tree root)
root
- The root within which this tree node is contained
public void insertDtr(Tree dtr, int position)
dtr
after position
existing
daughters in this
.
public String value()
Label
value
in interface Label
public void setValue(String value)
Label
setValue
in interface Label
value
- - the value for the labelpublic void setFromString(String labelStr)
Label
String
representing the
complete contents of the label. A class implementing label may
throw an UnsupportedOperationException
for this
method (only). Typically, this method would do
some appropriate decoding of the string in a way that sets
multiple fields in an inverse of the toString()
method.
setFromString
in interface Label
labelStr
- the String that translates into the content of the
labelpublic LabelFactory labelFactory()
null
if no appropriate factory is known.
labelFactory
in interface Label
public int leftCharEdge(Tree node)
public int rightCharEdge(Tree node)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |