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

java.lang.Object
  extended by se.lth.cs.nlp.nlputils.pstree.Node
      extended by se.lth.cs.nlp.nlputils.pstree.NonterminalNode

public class NonterminalNode
extends Node

Non-terminal node in a phrase structure tree.

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

Field Summary
 ArrayList<Node> children
          The children of the node.
 TokenNode head
          The head token node.
 Node headChild
          The child that contains the head.
 String label
          The label of the node.
(package private)  String secondLabel
           
(package private)  String tmpHeadToken
           
 
Fields inherited from class se.lth.cs.nlp.nlputils.pstree.Node
parent
 
Constructor Summary
NonterminalNode()
           
 
Method Summary
 TokenNode getFirstToken()
          Returns the leftmost dependent token.
 TokenNode getHead()
          Returns the head token node.
 String getLabel()
          For a token node, returns the part of speech; for a nonterminal node, returns its label.
 TokenNode getLastToken()
          Returns the rightmost dependent token.
 boolean isSameOrAncestorOf(Node n)
          Returns true if this node is identical to or is an ancestor of n.
(package private)  void setHeads()
          Uses the head rules described in Collins' thesis to find the heads of the nodes.
(package private)  void setHeadsSwedish()
           
 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.
 String toString()
           
 
Methods inherited from class se.lth.cs.nlp.nlputils.pstree.Node
overlaps
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

label

public String label
The label of the node.


head

public TokenNode head
The head token node.


children

public ArrayList<Node> children
The children of the node.


headChild

public Node headChild
The child that contains the head.


tmpHeadToken

String tmpHeadToken

secondLabel

String secondLabel
Constructor Detail

NonterminalNode

public NonterminalNode()
Method Detail

toString

public String toString()
Overrides:
toString in class Object

span

public Pair<Integer,Integer> span()
Description copied from class: Node
Returns the span of the node, that is the index of the leftmost dependent token and the index of the rightmost dependent token + 1.

Specified by:
span in class Node
Returns:
the span of the node.

isSameOrAncestorOf

public boolean isSameOrAncestorOf(Node n)
Description copied from class: Node
Returns true if this node is identical to or is an ancestor of n.

Specified by:
isSameOrAncestorOf in class Node
Parameters:
n - the node.
Returns:
true if this node is identical to or is an ancestor of n.

getLastToken

public TokenNode getLastToken()
Description copied from class: Node
Returns the rightmost dependent token.

Specified by:
getLastToken in class Node
Returns:
the rightmost dependent token.

getFirstToken

public TokenNode getFirstToken()
Description copied from class: Node
Returns the leftmost dependent token.

Specified by:
getFirstToken in class Node
Returns:
the rightmost dependent token.

getLabel

public String getLabel()
Description copied from class: Node
For a token node, returns the part of speech; for a nonterminal node, returns its label.

Specified by:
getLabel in class Node
Returns:
the label.

getHead

public TokenNode getHead()
Description copied from class: Node
Returns the head token node.

Specified by:
getHead in class Node
Returns:
the head token node.

setHeads

void setHeads()
Uses the head rules described in Collins' thesis to find the heads of the nodes.

Overrides:
setHeads in class Node

setHeadsSwedish

void setHeadsSwedish()
Overrides:
setHeadsSwedish in class Node