up
Class Backpointer

java.lang.Object
  extended by up.Backpointer

public class Backpointer
extends java.lang.Object

A backpointer to be used in CKY parsing. A backpointer specifies a recipe for how to build a tree. It consists of a rule, which defines a tree of depth 1, and up to two references to other backpointers, which recursively define the immediate subtrees.


Constructor Summary
Backpointer(BinaryRule rule, Backpointer pointerL, Backpointer pointerR)
          Create a new backpointer based on a binary rule.
Backpointer(PreterminalRule rule)
          Create a new backpointer based on a preterminal rule.
Backpointer(UnaryRule rule, Backpointer pointer)
          Create a new backpointer based on a unary rule.
 
Method Summary
 Tree extract(Grammar grammar)
          Return the tree specified by this backpointer.
 Backpointer getPointerL()
          Returns the backpointer for the left subtree.
 Backpointer getPointerR()
          Returns the backpointer for the right subtree.
 Rule getRule()
          Returns the rule associated with this backpointer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Backpointer

public Backpointer(PreterminalRule rule)
Create a new backpointer based on a preterminal rule.

Parameters:
rule - a preterminal rule

Backpointer

public Backpointer(UnaryRule rule,
                   Backpointer pointer)
Create a new backpointer based on a unary rule.

Parameters:
rule - a unary rule
pointer - a backpointer to the subtree

Backpointer

public Backpointer(BinaryRule rule,
                   Backpointer pointerL,
                   Backpointer pointerR)
Create a new backpointer based on a binary rule.

Parameters:
rule - a binary rule
pointerL - a backpointer for the left subtree
pointerR - a backpointer for the right subtree
Method Detail

getRule

public Rule getRule()
Returns the rule associated with this backpointer.

Returns:
the rule associated with this backpointer

getPointerL

public Backpointer getPointerL()
Returns the backpointer for the left subtree.

Returns:
the backpointer for the left subtree, or null in case no such backpointer is specified

getPointerR

public Backpointer getPointerR()
Returns the backpointer for the right subtree.

Returns:
the backpointer for the right subtree, or null in case no such backpointer is specified

extract

public Tree extract(Grammar grammar)
Return the tree specified by this backpointer. The rules used in the backpointer and its substructures will be interpreted with respect to the specified grammar.

Parameters:
grammar - a grammar
Returns:
the tree specified by this backpointer