edu.stanford.nlp.trees
Class LabeledScoredTreeLeaf

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--edu.stanford.nlp.trees.Tree
              |
              +--edu.stanford.nlp.trees.LabeledScoredTreeLeaf
All Implemented Interfaces:
Collection, Labeled, Scored

public final class LabeledScoredTreeLeaf
extends Tree

A LabeledScoredTreeLeaf represents the leaf of a tree in a parse tree with labels and scores.


Constructor Summary
LabeledScoredTreeLeaf()
          Create an empty leaf parse tree with an empty word.
LabeledScoredTreeLeaf(Label label)
          Create a leaf parse tree with given word.
LabeledScoredTreeLeaf(Label label, double score)
          Create a leaf parse tree with given word and score.
 
Method Summary
 Tree[] children()
          Leaves have no children.
static TreeFactory factory()
          Return a TreeFactory that produces trees of the LabeledScoredTree{Node|Leaf} type.
static TreeFactory factory(LabelFactory lf)
          Return a TreeFactory that produces trees of the LabeledScoredTree{Node|Leaf} type, with the Label made with the supplied LabelFactory.
 boolean isLeaf()
          Indicates that this is a leaf.
 Label label()
          Returns the label associated with the current node.
 double score()
          Returns the node's score.
 void setChildren(Tree[] children)
          Leaves have no children.
 void setLabel(Label label)
          Sets the label associated with the current node, if there is one.
 void setScore(double score)
          Sets the score associated with the current node, if there is one.
 String toString()
          Convert tree leaf to its label's string.
 StringBuffer toStringBuffer(StringBuffer sb)
          Appends the printed form of a parse tree (as a bracketed String) to a StringBuffer.
 TreeFactory treeFactory()
          Return a TreeFactory that produces trees of the same type as the current Tree.
 
Methods inherited from class edu.stanford.nlp.trees.Tree
constituents, constituents, deepCopy, deepCopy, depth, firstChild, getChildrenAsList, indentedListPrint, indentedListPrint, isPreTerminal, iterator, labels, lastChild, parent, parent, pennPrint, pennPrint, percolateHeads, preTerminalYield, preTerminalYield, prune, prune, setChildren, setLabels, size, spliceOut, spliceOut, subTrees, subTrees, taggedYield, taggedYield, transform, transform, yield, yield
 
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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

LabeledScoredTreeLeaf

public LabeledScoredTreeLeaf()
Create an empty leaf parse tree with an empty word.


LabeledScoredTreeLeaf

public LabeledScoredTreeLeaf(Label label)
Create a leaf parse tree with given word.

Parameters:
label - the Label representing the word for this new tree leaf.

LabeledScoredTreeLeaf

public LabeledScoredTreeLeaf(Label label,
                             double score)
Create a leaf parse tree with given word and score.

Parameters:
label - The Label representing the word for
score - The score for the node this new tree leaf.
Method Detail

isLeaf

public boolean isLeaf()
Indicates that this is a leaf. CHRIS: is adding this actually a speed-up or a slowdown? Check!

Overrides:
isLeaf in class Tree
Returns:
Whether this is a leaf node

children

public Tree[] children()
Leaves have no children.

Specified by:
children in class Tree
Returns:
null
See Also:
Tree.getChildrenAsList()

setChildren

public void setChildren(Tree[] children)
Leaves have no children.

Specified by:
setChildren in class Tree
Parameters:
children - The children for the node
See Also:
Tree.setChildren(List)

toString

public String toString()
Convert tree leaf to its label's string.

Overrides:
toString in class Tree
Returns:
Node's label in String form

toStringBuffer

public StringBuffer toStringBuffer(StringBuffer sb)
Appends the printed form of a parse tree (as a bracketed String) to a StringBuffer.

Overrides:
toStringBuffer in class Tree
Parameters:
sb - An input StringBuffer which is appended to
Returns:
StringBuffer returns the StringBuffer

label

public Label label()
Returns the label associated with the current node.

Specified by:
label in interface Labeled
Overrides:
label in class Tree
Returns:
The label associated with the current node, or null if there is no label

setLabel

public void setLabel(Label label)
Sets the label associated with the current node, if there is one.

Specified by:
setLabel in interface Labeled
Overrides:
setLabel in class Tree
Parameters:
label - The label of the node

score

public double score()
Returns the node's score.

Specified by:
score in interface Scored
Overrides:
score in class Tree
Returns:
The score associated with the current node, or NaN if there is no score

setScore

public void setScore(double score)
Sets the score associated with the current node, if there is one.

Overrides:
setScore in class Tree
Parameters:
score - Score of node

treeFactory

public TreeFactory treeFactory()
Return a TreeFactory that produces trees of the same type as the current Tree. That is, this implementation, will produce trees of type LabeledScoredTree(Node|Leaf). 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 StringLabelFactory will be used. The factories returned on different calls a different: a new one is allocated each time.

Specified by:
treeFactory in class Tree
Returns:
a factory to produce labeled, scored trees

factory

public static TreeFactory factory()
Return a TreeFactory that produces trees of the LabeledScoredTree{Node|Leaf} type. The factory returned is always the same one (a singleton).

Returns:
a factory to produce labeled, scored trees

factory

public static TreeFactory factory(LabelFactory lf)
Return a TreeFactory that produces trees of the LabeledScoredTree{Node|Leaf} type, with the Label made with the supplied LabelFactory. The factory returned is a different one each time

Parameters:
lf - The LabelFactory to use
Returns:
a factory to produce labeled, scored trees


Stanford NLP Group