Parsing Engine

danbikel.parser
Class HeadTreeNode

java.lang.Object
  extended by danbikel.parser.HeadTreeNode
All Implemented Interfaces:
SexpConvertible, Serializable

public class HeadTreeNode
extends Object
implements Serializable, SexpConvertible

Provides a convenient data structure for navigating a parse tree in which heads have been found and percolated up through the tree. This data structure mirrors the head relations of this parser, where the underlying lexicalized grammar productions are of the form

P → LnLn-1 H Rn-1Rn
Since the order of the modifying nonterminals is from adjacent to the head outward, this data structure stores modifying nonterminals in this order.

See Also:
Serialized Form

Constructor Summary
HeadTreeNode(Sexp tree)
          Constructs a new instance from the specified parse tree.
 
Method Summary
 boolean containsVerb()
          Indicates whether this subtree contains a verb.
protected  Symbol getHeadWordLabel()
           
 HeadTreeNode headChild()
          Gets the head child of this node.
 Word headWord()
          Gets the head word for this node.
 int headWordIdx()
          Gets the index of the head word for this node.
 boolean isPreterminal()
          Returns whether this node represents a preterminal.
 Symbol label()
          Gets the nonterminal label for this node.
 int leftIdx()
          Gets the index of the leftmost word in this subtree.
static void main(String[] args)
           
 Symbol originalHeadWord()
          Gets the original version of the head word.
 List postMods()
          Gets the list of postmodifiers of the head child of this node.
 List preMods()
          Gets the list of premodifiers of the head child of this node.
 int rightIdx()
          Gets the index of the rightmost word in this subtree plus 1.
 void setOriginalHeadWord(Symbol originalHeadWord)
          Sets the original version of the head word of this node, before any downcasing or other transformations were applied during training.
 Sexp toSexp()
          Converts this object to an S-expression.
 Sexp toSexp(boolean addHeadWords)
           
 String toString()
          Returns a string representation of the tree rooted at this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HeadTreeNode

public HeadTreeNode(Sexp tree)
Constructs a new instance from the specified parse tree.

Parameters:
tree - the parse tree from which to construct a new HeadTreeNode
Method Detail

isPreterminal

public boolean isPreterminal()
Returns whether this node represents a preterminal.

Returns:
whether this node represents a preterminal.

label

public Symbol label()
Gets the nonterminal label for this node.


headWord

public Word headWord()
Gets the head word for this node.


headWordIdx

public int headWordIdx()
Gets the index of the head word for this node.


originalHeadWord

public Symbol originalHeadWord()
Gets the original version of the head word.


containsVerb

public boolean containsVerb()
Indicates whether this subtree contains a verb.


headChild

public HeadTreeNode headChild()
Gets the head child of this node.


preMods

public List preMods()
Gets the list of premodifiers of the head child of this node.


postMods

public List postMods()
Gets the list of postmodifiers of the head child of this node.


leftIdx

public int leftIdx()
Gets the index of the leftmost word in this subtree.


rightIdx

public int rightIdx()
Gets the index of the rightmost word in this subtree plus 1.


setOriginalHeadWord

public void setOriginalHeadWord(Symbol originalHeadWord)
Sets the original version of the head word of this node, before any downcasing or other transformations were applied during training.

Parameters:
originalHeadWord - the original head word to set for this node

toSexp

public Sexp toSexp()
Description copied from interface: SexpConvertible
Converts this object to an S-expression.

Specified by:
toSexp in interface SexpConvertible
Returns:
the S-expression that represents an instance of an implementor of this class

toSexp

public Sexp toSexp(boolean addHeadWords)

getHeadWordLabel

protected Symbol getHeadWordLabel()

toString

public String toString()
Returns a string representation of the tree rooted at this node.

Overrides:
toString in class Object
Returns:
a string representation of the tree rooted at this node

main

public static void main(String[] args)

Parsing Engine

Author: Dan Bikel.