public class Trees
extends java.lang.Object
Tree
class.Modifier and Type | Method and Description |
---|---|
static Tree |
applyToProjections(TreeVisitor v,
Tree head,
Tree root,
HeadFinder hf) |
static void |
convertToCoreLabels(Tree tree)
Converts the tree labels to CoreLabels.
|
static Tree |
getLeaf(Tree tree,
int i)
Gets the ith leaf of a tree from the left.
|
static Tree |
getLowestCommonAncestor(java.util.List<Tree> nodes,
Tree root)
Get lowest common ancestor of all the nodes in the list with the tree rooted at root
|
static Tree |
getLowestCommonAncestor(Tree t1,
Tree t2,
Tree root)
returns the node of a tree which represents the lowest common
ancestor of nodes t1 and t2 dominated by root.
|
static Tree |
getPreTerminal(Tree tree,
int n)
gets the
n th preterminal in tree . |
static Tree |
getTerminal(Tree tree,
int n)
gets the
n th terminal in tree . |
static int |
height(Tree t)
Recursively calculate the max height of the given tree
|
static java.util.List<Label> |
leafLabels(Tree t)
returns the labels of the leaves in a Tree in the order that they're found.
|
static java.util.List<Tree> |
leaves(Tree t)
returns the leaves in a Tree in the order that they're found.
|
static int |
leftEdge(Tree t,
Tree root)
Returns the positional index of the left edge of a tree t
within a given root, as defined by the size of the yield of all
material preceding t.
|
static int |
leftEdgeUnsafe(Tree t,
Tree root)
Returns the positional index of the left edge of a tree t
within a given root, as defined by the size of the yield of all
material preceding t.
|
static Tree |
lexicalize(Tree t,
HeadFinder hf)
Returns a lexicalized Tree whose Labels are CategoryWordTag
instances, all corresponds to the input tree.
|
static java.util.List<java.lang.String> |
localTreeAsCatList(Tree t)
returns the syntactic category of the tree as a list of the syntactic categories of the mother and the daughters
|
static void |
main(java.lang.String[] args) |
static Tree |
maximalProjection(Tree head,
Tree root,
HeadFinder hf)
|
static Tree |
normalizeTree(Tree tree,
TreeNormalizer tn,
TreeFactory tf) |
static int |
objectEqualityIndexOf(Tree parent,
Tree daughter)
Returns the index of
daughter in parent by ==. |
static void |
outputTreeLabels(Tree tree)
Outputs the labels on the trees, not just the words.
|
static java.util.List<Tree> |
pathFromRoot(Tree t,
Tree root)
returns list of tree nodes to root from t.
|
static java.util.List<java.lang.String> |
pathNodeToNode(Tree from,
Tree to,
Tree root)
returns a list of categories that is the path from Tree from to Tree
to within Tree root.
|
static java.util.List<Tree> |
preTerminals(Tree t) |
static Tree |
readTree(java.lang.String str)
Simple tree reading utility method.
|
static Tree |
readTree(java.lang.String ptbTreeString,
TreeFactory treeFactory)
Simple tree reading utility method.
|
static void |
replaceNode(Tree node,
Tree node1,
Tree t)
replaces all instances (by ==) of node with node1.
|
static int |
rightEdge(Tree t,
Tree root)
Returns the positional index of the right edge of a tree
t within a given root, as defined by the size of the yield
of all material preceding t plus all the material
contained in t.
|
static int |
rightEdgeUnsafe(Tree t,
Tree root)
Returns the positional index of the right edge of a tree
t within a given root, as defined by the size of the yield
of all material preceding t plus all the material
contained in t.
|
static void |
setLeafLabels(Tree tree,
java.util.List<? extends Label> labels)
Replace the labels of the leaves with the given leaves.
|
static void |
setLeafTagsIfUnset(Tree tree)
Given a tree, set the tags on the leaf nodes if they are not
already set.
|
static void |
setSentIndex(Tree tree,
int sentIndex)
Set the sentence index of all the leaves in the tree
(only works on CoreLabel)
|
static java.util.List<CoreLabel> |
taggedLeafLabels(Tree t)
returns the labels of the leaves in a Tree, augmented with POS tags.
|
static Tree |
toFlatTree(java.util.List<? extends HasWord> s,
LabelFactory lf)
Turns a sentence into a flat phrasal tree.
|
static Tree |
toFlatTree(java.util.List<HasWord> s)
Turns a sentence into a flat phrasal tree.
|
static java.lang.String |
toStructureDebugString(Tree t)
Returns a String reporting what kinds of Tree and Label nodes this
Tree contains.
|
static java.lang.String |
treeToLatex(Tree t) |
static java.lang.String |
treeToLatexEven(Tree t) |
public static int height(Tree t)
public static int leftEdge(Tree t, Tree root)
public static int leftEdgeUnsafe(Tree t, Tree root)
leftEdge(Tree, Tree)
public static int rightEdge(Tree t, Tree root)
public static int rightEdgeUnsafe(Tree t, Tree root)
rightEdge(Tree, Tree)
public static Tree lexicalize(Tree t, HeadFinder hf)
public static java.util.List<Tree> leaves(Tree t)
public static java.util.List<Label> leafLabels(Tree t)
public static java.util.List<CoreLabel> taggedLeafLabels(Tree t)
public static void setLeafTagsIfUnset(Tree tree)
public static void setLeafLabels(Tree tree, java.util.List<? extends Label> labels)
public static Tree maximalProjection(Tree head, Tree root, HeadFinder hf)
public static Tree applyToProjections(TreeVisitor v, Tree head, Tree root, HeadFinder hf)
public static Tree getTerminal(Tree tree, int n)
n
th terminal in tree
. The first terminal is number zero.public static Tree getPreTerminal(Tree tree, int n)
n
th preterminal in tree
. The first terminal is number zero.public static java.util.List<java.lang.String> localTreeAsCatList(Tree t)
public static int objectEqualityIndexOf(Tree parent, Tree daughter)
daughter
in parent
by ==.
Returns -1 if daughter
not found.public static java.lang.String toStructureDebugString(Tree t)
t
- The tree to examine.public static Tree toFlatTree(java.util.List<HasWord> s)
s
- The Sentence to make the Tree frompublic static Tree toFlatTree(java.util.List<? extends HasWord> s, LabelFactory lf)
s
- The Sentence to make the Tree fromlf
- The LabelFactory with which to create the new Tree labelspublic static java.lang.String treeToLatex(Tree t)
public static java.lang.String treeToLatexEven(Tree t)
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
public static Tree normalizeTree(Tree tree, TreeNormalizer tn, TreeFactory tf)
public static Tree getLeaf(Tree tree, int i)
null
if there is no such leaf.public static Tree getLowestCommonAncestor(java.util.List<Tree> nodes, Tree root)
public static java.util.List<java.lang.String> pathNodeToNode(Tree from, Tree to, Tree root)
public static java.util.List<Tree> pathFromRoot(Tree t, Tree root)
public static void replaceNode(Tree node, Tree node1, Tree t)
public static Tree getLowestCommonAncestor(Tree t1, Tree t2, Tree root)
public static Tree readTree(java.lang.String ptbTreeString, TreeFactory treeFactory)
public static Tree readTree(java.lang.String str)
public static void outputTreeLabels(Tree tree)
public static void convertToCoreLabels(Tree tree)
tree
- Any treepublic static void setSentIndex(Tree tree, int sentIndex)