Class Tree

    • Constructor Detail

      • Tree

        public Tree​(Tree tree)
        Clone constructor (all but the children)
        Parameters:
        tree - the tree to clone
    • 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
      • children

        public List<Tree> children()
      • 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 TreeList<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 TreeList<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)
      • setTokens

        public void setTokens​(List<String> tokens)
      • setParent

        public void setParent​(Tree parent)
      • parent

        public Tree parent()
      • setVector

        public void setVector​(INDArray vector)
      • prediction

        public INDArray prediction()
      • setPrediction

        public void setPrediction​(INDArray prediction)
      • setTags

        public void setTags​(List<String> tags)
      • getChildren

        public List<Tree> getChildren()
      • 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)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object