Class Tree
- java.lang.Object
-
- org.deeplearning4j.nn.layers.feedforward.autoencoder.recursive.Tree
-
- All Implemented Interfaces:
Serializable
public class Tree extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tree
ancestor(int height, Tree root)
Returns the ancestor of the given treeList<Tree>
children()
Tree
clone()
void
connect(List<Tree> children)
Connects the given trees and sets the parents of the childrenint
depth()
Finds the channels of the tree.int
depth(Tree node)
Returns the distance between this node and the specified subnodeboolean
equals(Object o)
double
error()
Returns the prediction error for this nodedouble
errorSum()
Returns the total prediction error for this tree and its childrenTree
firstChild()
int
getBegin()
List<Tree>
getChildren()
int
getEnd()
String
getHeadWord()
<T extends Tree>
List<T>getLeaves()
Gets the leaves of the tree.<T extends Tree>
List<T>getLeaves(List<T> list)
Gets the leaves of the tree.List<String>
getTokens()
String
getType()
The type of node; mainly extra meta dataint
goldLabel()
int
hashCode()
boolean
isLeaf()
Returns whether the node has any children or notboolean
isPreTerminal()
Node has one child that is a leafString
label()
Tree
lastChild()
Tree
parent()
Tree
parent(Tree root)
Returns the parent of the passed in tree via traversalINDArray
prediction()
void
setBegin(int begin)
void
setEnd(int end)
void
setError(double error)
void
setGoldLabel(int goldLabel)
void
setHeadWord(String headWord)
void
setLabel(String label)
void
setParent(Tree parent)
void
setParse(String parse)
void
setPrediction(INDArray prediction)
void
setTags(List<String> tags)
void
setTokens(List<String> tokens)
void
setType(String type)
void
setValue(String value)
void
setVector(INDArray vector)
List<String>
tags()
String
toString()
String
value()
INDArray
vector()
List<String>
yield()
Returns all of the labels for this node and all of its children (recursively)
-
-
-
Method Detail
-
getType
public String getType()
The type of node; mainly extra meta data- Returns:
-
setType
public void setType(String type)
-
yield
public List<String> yield()
Returns all of the labels for this node and all of its children (recursively)- Returns:
- all of the labels of this node and its children recursively
-
setGoldLabel
public void setGoldLabel(int goldLabel)
-
goldLabel
public int goldLabel()
-
setLabel
public void setLabel(String label)
-
label
public String label()
-
value
public String value()
-
setValue
public void setValue(String value)
-
isLeaf
public boolean isLeaf()
Returns whether the node has any children or not- Returns:
- whether the node has any children or not
-
isPreTerminal
public boolean isPreTerminal()
Node has one child that is a leaf- Returns:
- whether the node has one child and the child is a leaf
-
firstChild
public Tree firstChild()
-
lastChild
public Tree lastChild()
-
depth
public int depth()
Finds the channels of the tree. The channels is defined as the length of the longest path from this node to a leaf node. Leaf nodes have channels zero. POS tags have channels 1. Phrasal nodes have channels >= 2.- Returns:
- the channels
-
depth
public int depth(Tree node)
Returns the distance between this node and the specified subnode- Parameters:
node
- the node to get the distance from- Returns:
- the distance between the 2 nodes
-
parent
public Tree parent(Tree root)
Returns the parent of the passed in tree via traversal- Parameters:
root
- the root node- Returns:
- the tree to traverse
-
ancestor
public Tree ancestor(int height, Tree root)
Returns the ancestor of the given tree- Parameters:
height
-root
-- Returns:
Tree
-
errorSum
public double errorSum()
Returns the total prediction error for this tree and its children- Returns:
- the total error for this tree and its children
-
getLeaves
public <T extends Tree> List<T> getLeaves()
Gets the leaves of the tree. All leaves nodes are returned as a list ordered by the natural left to right order of the tree. Null values, if any, are inserted into the list like any other value.- Returns:
- a
List
of the leaves.
-
getLeaves
public <T extends Tree> List<T> getLeaves(List<T> list)
Gets the leaves of the tree.- Parameters:
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.- Returns:
- a
List
of the leaves.
-
error
public double error()
Returns the prediction error for this node- Returns:
- the prediction error for this node
-
setError
public void setError(double error)
-
setParent
public void setParent(Tree parent)
-
parent
public Tree parent()
-
vector
public INDArray vector()
-
setVector
public void setVector(INDArray vector)
-
prediction
public INDArray prediction()
-
setPrediction
public void setPrediction(INDArray prediction)
-
getHeadWord
public String getHeadWord()
-
setHeadWord
public void setHeadWord(String headWord)
-
setParse
public void setParse(String parse)
-
connect
public void connect(List<Tree> children)
Connects the given trees and sets the parents of the children- Parameters:
children
- the children to connect with
-
getBegin
public int getBegin()
-
setBegin
public void setBegin(int begin)
-
getEnd
public int getEnd()
-
setEnd
public void setEnd(int end)
-
-