public class Tree
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Tree(java.util.List<java.lang.String> tokens) |
Tree(Tree tree)
Clone constructor (all but the children)
|
Tree(Tree parent,
java.util.List<java.lang.String> tokens) |
Modifier and Type | Method and Description |
---|---|
Tree |
ancestor(int height,
Tree root)
Returns the ancestor of the given tree
|
java.util.List<Tree> |
children() |
Tree |
clone() |
void |
connect(java.util.List<Tree> children)
Connects the given trees
and sets the parents of the children
|
int |
depth()
Finds the depth of the tree.
|
int |
depth(Tree node)
Returns the distance between this node
and the specified subnode
|
boolean |
equals(java.lang.Object o) |
double |
error()
Returns the prediction error for this node
|
double |
errorSum()
Returns the total prediction error for this
tree and its children
|
Tree |
firstChild() |
int |
getBegin() |
java.util.List<Tree> |
getChildren() |
int |
getEnd() |
java.lang.String |
getHeadWord() |
<T extends Tree> |
getLeaves()
Gets the leaves of the tree.
|
<T extends Tree> |
getLeaves(java.util.List<T> list)
Gets the leaves of the tree.
|
java.util.List<java.lang.String> |
getTokens() |
java.lang.String |
getType()
The type of node; mainly extra meta data
|
int |
goldLabel() |
int |
hashCode() |
boolean |
isLeaf()
Returns whether the node has any children or not
|
boolean |
isPreTerminal()
Node has one child that is a leaf
|
java.lang.String |
label() |
Tree |
lastChild() |
Tree |
parent() |
Tree |
parent(Tree root)
Returns the parent of the passed in tree via traversal
|
org.nd4j.linalg.api.ndarray.INDArray |
prediction() |
void |
setBegin(int begin) |
void |
setEnd(int end) |
void |
setError(double error) |
void |
setGoldLabel(int goldLabel) |
void |
setHeadWord(java.lang.String headWord) |
void |
setLabel(java.lang.String label) |
void |
setParent(Tree parent) |
void |
setParse(java.lang.String parse) |
void |
setPrediction(org.nd4j.linalg.api.ndarray.INDArray prediction) |
void |
setTags(java.util.List<java.lang.String> tags) |
void |
setTokens(java.util.List<java.lang.String> tokens) |
void |
setType(java.lang.String type) |
void |
setValue(java.lang.String value) |
void |
setVector(org.nd4j.linalg.api.ndarray.INDArray vector) |
java.util.List<java.lang.String> |
tags() |
java.lang.String |
toString() |
java.lang.String |
value() |
org.nd4j.linalg.api.ndarray.INDArray |
vector() |
java.util.List<java.lang.String> |
yield()
Returns all of the labels for this node and all of its children (recursively)
|
public Tree(Tree tree)
tree
- the tree to clonepublic Tree(Tree parent, java.util.List<java.lang.String> tokens)
public Tree(java.util.List<java.lang.String> tokens)
public java.lang.String getType()
public void setType(java.lang.String type)
public java.util.List<java.lang.String> yield()
public void setGoldLabel(int goldLabel)
public int goldLabel()
public void setLabel(java.lang.String label)
public java.lang.String label()
public java.lang.String value()
public void setValue(java.lang.String value)
public boolean isLeaf()
public java.util.List<Tree> children()
public boolean isPreTerminal()
public Tree firstChild()
public Tree lastChild()
public int depth()
public int depth(Tree node)
node
- the node to getFromOrigin the distance frompublic Tree parent(Tree root)
root
- the root nodepublic Tree ancestor(int height, Tree root)
height
- root
- Tree
public double errorSum()
public <T extends Tree> java.util.List<T> getLeaves()
List
of the leaves.public <T extends Tree> java.util.List<T> getLeaves(java.util.List<T> 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 Tree clone()
clone
in class java.lang.Object
public double error()
public void setError(double error)
public java.util.List<java.lang.String> getTokens()
public void setTokens(java.util.List<java.lang.String> tokens)
public void setParent(Tree parent)
public Tree parent()
public org.nd4j.linalg.api.ndarray.INDArray vector()
public void setVector(org.nd4j.linalg.api.ndarray.INDArray vector)
public org.nd4j.linalg.api.ndarray.INDArray prediction()
public void setPrediction(org.nd4j.linalg.api.ndarray.INDArray prediction)
public java.util.List<java.lang.String> tags()
public void setTags(java.util.List<java.lang.String> tags)
public java.util.List<Tree> getChildren()
public java.lang.String getHeadWord()
public void setHeadWord(java.lang.String headWord)
public void setParse(java.lang.String parse)
public void connect(java.util.List<Tree> children)
children
- the children to connect withpublic int getBegin()
public void setBegin(int begin)
public int getEnd()
public void setEnd(int end)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object