se.lth.cs.nlp.nlputils.pstree
Class Node

java.lang.Object
  extended by se.lth.cs.nlp.nlputils.pstree.Node
Direct Known Subclasses:
NonterminalNode, TokenNode

public abstract class Node
extends Object

A node in a phrase structure tree. Is either a TokenNode or a NonterminalNode.

Author:
Richard Johansson (richard@cs.lth.se)

Field Summary
 NonterminalNode parent
          Parent node.
 
Constructor Summary
Node()
           
 
Method Summary
abstract  TokenNode getFirstToken()
          Returns the leftmost dependent token.
abstract  TokenNode getHead()
          Returns the head token node.
abstract  String getLabel()
          For a token node, returns the part of speech; for a nonterminal node, returns its label.
abstract  TokenNode getLastToken()
          Returns the rightmost dependent token.
abstract  boolean isSameOrAncestorOf(Node n)
          Returns true if this node is identical to or is an ancestor of n.
 boolean overlaps(Node n2)
          Returns true if the spans of the nodes overlap.
(package private)  void setHeads()
           
(package private)  void setHeadsSwedish()
           
abstract  Pair<Integer,Integer> span()
          Returns the span of the node, that is the index of the leftmost dependent token and the index of the rightmost dependent token + 1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

public NonterminalNode parent
Parent node.

Constructor Detail

Node

public Node()
Method Detail

span

public abstract Pair<Integer,Integer> span()
Returns the span of the node, that is the index of the leftmost dependent token and the index of the rightmost dependent token + 1.

Returns:
the span of the node.

isSameOrAncestorOf

public abstract boolean isSameOrAncestorOf(Node n)
Returns true if this node is identical to or is an ancestor of n.

Parameters:
n - the node.
Returns:
true if this node is identical to or is an ancestor of n.

getLabel

public abstract String getLabel()
For a token node, returns the part of speech; for a nonterminal node, returns its label.

Returns:
the label.

getHead

public abstract TokenNode getHead()
Returns the head token node.

Returns:
the head token node.

getLastToken

public abstract TokenNode getLastToken()
Returns the rightmost dependent token.

Returns:
the rightmost dependent token.

getFirstToken

public abstract TokenNode getFirstToken()
Returns the leftmost dependent token.

Returns:
the rightmost dependent token.

overlaps

public boolean overlaps(Node n2)
Returns true if the spans of the nodes overlap.

Parameters:
n2 - the other node.
Returns:
true if the spans of the nodes overlap.

setHeads

void setHeads()

setHeadsSwedish

void setHeadsSwedish()