MaltParser 1.0.2

org.maltparser.core.graph
Class Node

java.lang.Object
  extended by org.maltparser.core.graph.Node
All Implemented Interfaces:
Comparable<Node>, Featurable

public class Node
extends Object
implements Comparable<Node>, Featurable

Since:
1.0
Author:
Johan Hall

Field Summary
protected  HeadArcs arcs
          the head arcs that contains one or more labeled arcs (if singleHeadedConstraint==true, it contains only one arc per node)
protected  Node component
          a reference to a node where the node is part of a component.
protected  Integer index
          the node index
protected  SortedSet<Node> leftDependents
          a sorted set of left dependent nodes (sorted according to the node index)
protected  Node predecessor
          the previous node in the linear precedence
protected  int rank
           
protected  SortedSet<Node> rightDependents
          a sorted set of right dependent nodes (sorted according to the node index)
protected  boolean root
          true if the node is a root, otherwise false
protected  boolean singleHeadedConstraint
           
protected  Node successor
          the next node in the linear precedence
protected  Token token
          a reference to the token in the sentence
 
Constructor Summary
Node(int index, boolean isRoot, boolean isSingleHeaded)
           
Node(int index, boolean isRoot, boolean isSingleHeaded, Token token)
           
 
Method Summary
protected  void addDependent(Node dependent)
           
 void addHead(Node head)
           
 void addHead(Node head, ArcLabels arcLabelCodes)
           
 void clear()
           
 int compareTo(Node o)
           
 Node findComponent()
           
 ArcLabels getArcLabels(int headindex)
           
 Node getClosestLeftDependent()
          Returns the closest left dependent to the node it self, if not found null is returned.
 Node getClosestRightDependent()
          Returns the closest right dependent to the node it self, if not found null is returned.
 Node getComponent()
           
 Node getHead()
           
 Node getHead(int index)
           
 Integer getHeadLabelCode(SymbolTable table)
           
 SortedSet<Node> getHeads()
           
 Integer getIndex()
           
 ArcLabels getLabelCode()
           
 Integer getLabelCode(int headindex, SymbolTable table)
           
 Integer getLabelCode(Node head, SymbolTable table)
           
 Integer getLabelCode(SymbolTable table)
           
 Node getLeftDependent(int index)
          Returns the left dependent at the position index, where index==0 equals the left most dependent.
 int getLeftDependentCount()
          Return the number of left dependents
 SortedSet<Node> getLeftDependents()
          Returns a sorted set of left dependents
 Node getLeftmostDependent()
          Returns the left most dependent.
 Node getLeftmostDescendant()
           
 Node getLeftSibling()
          Returns the left sibling if it exists, otherwise null
 Node getNode(String operation, int index)
           
 Node getPredecessor()
          Returns the predecessor node in the input queue
 int getRank()
           
 Node getRightDependent(int index)
          Returns the right dependent at the position index, where index==0 equals the right most dependent.
 int getRightDependentCount()
          Return the number of right dependents
 SortedSet<Node> getRightDependents()
          Returns a sorted set of right dependent nodes
 Node getRightmostDependent()
          Returns the right most dependent.
 Node getRightmostDescendant()
           
 Node getRightSibling()
          Returns the right sibling if it exists, otherwise null
 Node getSameSideLeftSibling()
          Returns the left sibling at the same side of head as the node it self.
 Node getSameSideRightSibling()
          Returns the right sibling at the same side of head as the node it self.
 Node getSuccessor()
          Returns the successor node in the input queue
 Token getToken()
           
 boolean hasAncestorInside(int left, int right)
           
 boolean hasHead()
           
 boolean hasLabelCodes()
           
 boolean hasLeftDependent()
          Returns true if the node has one or more left dependents, otherwise false.
 boolean hasRightDependent()
          Returns true if the node has one or more right dependents, otherwise false.
protected  void initArcs()
           
 boolean isOperation(String operation)
           
 boolean isRoot()
           
 boolean isSingleHeaded()
           
 boolean isSingleHeadedConstraint()
           
protected  void removeDependent(Node dependent)
           
 void setComponent(Node x)
           
protected  void setIndex(Integer index)
           
 void setPredecessor(Node predecessor)
           
 void setRank(int r)
           
protected  void setRoot(boolean root)
           
protected  void setSingleHeadedConstraint(boolean singleHeadedConstraint)
           
 void setSuccessor(Node successor)
           
protected  void setToken(Token token)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

index

protected Integer index
the node index


predecessor

protected Node predecessor
the previous node in the linear precedence


successor

protected Node successor
the next node in the linear precedence


leftDependents

protected SortedSet<Node> leftDependents
a sorted set of left dependent nodes (sorted according to the node index)


rightDependents

protected SortedSet<Node> rightDependents
a sorted set of right dependent nodes (sorted according to the node index)


arcs

protected HeadArcs arcs
the head arcs that contains one or more labeled arcs (if singleHeadedConstraint==true, it contains only one arc per node)


token

protected Token token
a reference to the token in the sentence


component

protected Node component
a reference to a node where the node is part of a component. If the node is unconnected it will reference to it self.


rank

protected int rank

root

protected boolean root
true if the node is a root, otherwise false


singleHeadedConstraint

protected boolean singleHeadedConstraint
Constructor Detail

Node

public Node(int index,
            boolean isRoot,
            boolean isSingleHeaded)

Node

public Node(int index,
            boolean isRoot,
            boolean isSingleHeaded,
            Token token)
Method Detail

addHead

public void addHead(Node head)
             throws MaltChainedException
Throws:
MaltChainedException

addHead

public void addHead(Node head,
                    ArcLabels arcLabelCodes)
             throws MaltChainedException
Throws:
MaltChainedException

getRank

public int getRank()

setRank

public void setRank(int r)

findComponent

public Node findComponent()

getComponent

public Node getComponent()

setComponent

public void setComponent(Node x)

isSingleHeaded

public boolean isSingleHeaded()

getHead

public Node getHead(int index)

getLabelCode

public Integer getLabelCode(Node head,
                            SymbolTable table)

getLabelCode

public Integer getLabelCode(SymbolTable table)

getLabelCode

public ArcLabels getLabelCode()

hasLabelCodes

public boolean hasLabelCodes()

getHead

public Node getHead()

getHeads

public SortedSet<Node> getHeads()

getLabelCode

public Integer getLabelCode(int headindex,
                            SymbolTable table)

getArcLabels

public ArcLabels getArcLabels(int headindex)

getHeadLabelCode

public Integer getHeadLabelCode(SymbolTable table)

addDependent

protected void addDependent(Node dependent)
                     throws MaltChainedException
Throws:
MaltChainedException

removeDependent

protected void removeDependent(Node dependent)

clear

public void clear()

hasAncestorInside

public boolean hasAncestorInside(int left,
                                 int right)

isRoot

public boolean isRoot()

isSingleHeadedConstraint

public boolean isSingleHeadedConstraint()

getIndex

public Integer getIndex()

getToken

public Token getToken()

hasHead

public boolean hasHead()

getPredecessor

public Node getPredecessor()
Returns the predecessor node in the input queue

Returns:
the predecessor node in the input queue

getSuccessor

public Node getSuccessor()
Returns the successor node in the input queue

Returns:
the successor node in the input queue

getLeftSibling

public Node getLeftSibling()
Returns the left sibling if it exists, otherwise null

Returns:
the left sibling if it exists, otherwise null

getSameSideLeftSibling

public Node getSameSideLeftSibling()
Returns the left sibling at the same side of head as the node it self. If not found null
Returns:
the left sibling at the same side of head as the node it self. If not found null

getRightSibling

public Node getRightSibling()
Returns the right sibling if it exists, otherwise null

Returns:
the right sibling if it exists, otherwise null

getSameSideRightSibling

public Node getSameSideRightSibling()
Returns the right sibling at the same side of head as the node it self. If not found null
Returns:
the right sibling at the same side of head as the node it self. If not found null

hasLeftDependent

public boolean hasLeftDependent()
Returns true if the node has one or more left dependents, otherwise false.

Returns:
true if the node has one or more left dependents, otherwise false.

getLeftmostDependent

public Node getLeftmostDependent()
Returns the left most dependent. If the node does not have any left dependent(s) null is returned.

Returns:
the left most dependent. If the node does not have any left dependent(s) null is returned.

getClosestLeftDependent

public Node getClosestLeftDependent()
Returns the closest left dependent to the node it self, if not found null is returned.

Returns:
the closest left dependent to the node it self, if not found null is returned.

getLeftDependents

public SortedSet<Node> getLeftDependents()
Returns a sorted set of left dependents

Returns:
a sorted set of left dependents

getLeftDependent

public Node getLeftDependent(int index)
Returns the left dependent at the position index, where index==0 equals the left most dependent.

Parameters:
index - the index
Returns:
the left dependent at the position index, where index==0 equals the left most dependent

getLeftDependentCount

public int getLeftDependentCount()
Return the number of left dependents

Returns:
the number of left dependents

hasRightDependent

public boolean hasRightDependent()
Returns true if the node has one or more right dependents, otherwise false.

Returns:
true if the node has one or more right dependents, otherwise false.

getRightmostDependent

public Node getRightmostDependent()
Returns the right most dependent. If the node does not have any right dependent(s) null is returned.

Returns:
the right most dependent. If the node does not have any right dependent(s) null is returned.

getClosestRightDependent

public Node getClosestRightDependent()
Returns the closest right dependent to the node it self, if not found null is returned.

Returns:
the closest right dependent to the node it self, if not found null is returned.

getRightDependents

public SortedSet<Node> getRightDependents()
Returns a sorted set of right dependent nodes

Returns:
a sorted set of right dependent nodes

getRightDependent

public Node getRightDependent(int index)
Returns the right dependent at the position index, where index==0 equals the right most dependent.

Parameters:
index - the index
Returns:
the right dependent at the position index, where index==0 equals the right most dependent

getRightDependentCount

public int getRightDependentCount()
Return the number of right dependents

Returns:
the number of right dependents

getLeftmostDescendant

public Node getLeftmostDescendant()

getRightmostDescendant

public Node getRightmostDescendant()

isOperation

public boolean isOperation(String operation)
Specified by:
isOperation in interface Featurable

getNode

public Node getNode(String operation,
                    int index)
Specified by:
getNode in interface Featurable

setIndex

protected void setIndex(Integer index)

setPredecessor

public void setPredecessor(Node predecessor)

setSuccessor

public void setSuccessor(Node successor)

setRoot

protected void setRoot(boolean root)

setSingleHeadedConstraint

protected void setSingleHeadedConstraint(boolean singleHeadedConstraint)

setToken

protected void setToken(Token token)

initArcs

protected void initArcs()

compareTo

public int compareTo(Node o)
Specified by:
compareTo in interface Comparable<Node>

MaltParser 1.0.2

Copyright 2007 Johan Hall, Jens Nilsson and Joakim Nivre.