Parsing Engine

danbikel.parser.constraints
Class LexTreeConstraint

java.lang.Object
  extended by danbikel.parser.constraints.UnlexTreeConstraint
      extended by danbikel.parser.constraints.LexTreeConstraint
All Implemented Interfaces:
SexpConvertible, Constraint, Serializable

public class LexTreeConstraint
extends UnlexTreeConstraint

Specifies a node in a tree of constraints, to allow the decoder only to pursue theories that are consistent with a particular head-lexicalized tree.
Implementation note: The public constructor of this class expects a Sexp object representing an unlexicalized parse tree, which is lexicalized using the current head finder.

See Also:
Serialized Form

Field Summary
protected  Word headWord
          The head word associated with this constraint.
 
Fields inherited from class danbikel.parser.constraints.UnlexTreeConstraint
children, end, label, parent, satisfied, start
 
Constructor Summary
protected LexTreeConstraint(LexTreeConstraint parent, Sexp tree, IntCounter currWordIdx, HeadFinder headFinder)
          Constructs a tree of constraints that is isomorphic to the specified parse tree.
  LexTreeConstraint(Sexp tree)
          Constructs a tree of constraints that is isomorphic to the specified parse tree.
 
Method Summary
 boolean isLocallySatisfiedBy(Item item)
          Returns whether the specified item satisfies the local information of this constraint node, regardless of this node's place in a tree structure of constraints.
protected  boolean isSatisfiedByPreterminal(CKYItem item)
          Returns true if this constraint is locally satisfied by the specified item and if this constraint's span matches that of the specified item.
 Sexp toSexp()
          Returns a symbolic expression version of the constraint tree rooted at this constraint.
 String toString()
          A debugging method that returns a string representation of the information of this constraint.
 
Methods inherited from class danbikel.parser.constraints.UnlexTreeConstraint
end, getChildren, getParent, hasBeenSatisfied, isLeaf, isSatisfiedBy, isViolatedBy, isViolatedByChild, label, spanMatches, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

headWord

protected Word headWord
The head word associated with this constraint.

Constructor Detail

LexTreeConstraint

public LexTreeConstraint(Sexp tree)
Constructs a tree of constraints that is isomorphic to the specified parse tree. Head lexicalization of the specified parse tree is performed "on the fly" using the current head finder.

Parameters:
tree - the parse tree from which to construct an isomorphic tree of LexTreeConstraint nodes

LexTreeConstraint

protected LexTreeConstraint(LexTreeConstraint parent,
                            Sexp tree,
                            IntCounter currWordIdx,
                            HeadFinder headFinder)
Constructs a tree of constraints that is isomorphic to the specified parse tree.

Parameters:
parent - the parent constraint node of this node, or null if this node is the root of the constraint tree
tree - the (unlexicalized) parse tree from which to construct an isomorphic tree of constraints
currWordIdx - the zero-based index of the current word, as determined by the left-to-right, top-down traversal of the specified tree
headFinder - the HeadFinder instance to use to lexicalize the specified parse tree
Method Detail

isSatisfiedByPreterminal

protected boolean isSatisfiedByPreterminal(CKYItem item)
Returns true if this constraint is locally satisfied by the specified item and if this constraint's span matches that of the specified item. This overridden definition is in stark contrast to that of UnlexTreeConstraint, where preterminals are always satisfied by preterminal constraints, meaning that parts of speech are not constrained.

Overrides:
isSatisfiedByPreterminal in class UnlexTreeConstraint
Parameters:
item - the item to be tested
Returns:
true if this constraint is locally satisfied by the specified item and if this constraint's span matches that of the specified item.

isLocallySatisfiedBy

public boolean isLocallySatisfiedBy(Item item)
Returns whether the specified item satisfies the local information of this constraint node, regardless of this node's place in a tree structure of constraints. When bottom-up parsing and building a parse theory from some child item c, this method may be used to determine if some proposed parent item p locally satisfies the information contained in c.getConstraint().getParent(). That is, if
c.getConstraint().getParent().isLocallySatisfiedBy(p)
returns true, then theories building on the proposed parent item p should be pursued. Local constraint information may include, for example, a nonterminal label or span information.

Specified by:
isLocallySatisfiedBy in interface Constraint
Overrides:
isLocallySatisfiedBy in class UnlexTreeConstraint
Parameters:
item - the chart item to be tested against this constraint node that is part of a tree of constraint nodes
Returns:
whether the specified item satisfies the local information of this constraint node

toSexp

public Sexp toSexp()
Description copied from class: UnlexTreeConstraint
Returns a symbolic expression version of the constraint tree rooted at this constraint.

Specified by:
toSexp in interface SexpConvertible
Overrides:
toSexp in class UnlexTreeConstraint
Returns:
a symbolic expression version of the constraint tree rooted at this constraint

toString

public String toString()
A debugging method that returns a string representation of the information of this constraint.

Overrides:
toString in class UnlexTreeConstraint
Returns:
a string representation of the information of this constraint.

Parsing Engine

Author: Dan Bikel.