Parsing Engine

danbikel.parser.constraints
Class UnlexTreeConstraintSet

java.lang.Object
  extended by java.util.AbstractCollection
      extended by danbikel.parser.constraints.UnlexTreeConstraintSet
All Implemented Interfaces:
ConstraintSet, Iterable, Collection
Direct Known Subclasses:
LexTreeConstraintSet, PartialLexTreeConstraintSet

public class UnlexTreeConstraintSet
extends AbstractCollection
implements ConstraintSet

Represents a set of constraints that correspond to a specific unlexicalized parse tree, for use when the bottom-up parsing algorithm needs to generate only the analyses that are consistent with a particular unlexicalized tree. Accordingly, the individual Constraint objects in this set form an isomorphic tree structure.


Field Summary
protected  ArrayList leaves
          The leaves of this tree of constraints in their correct order as they correspond to single words (technically, preterminals) of a sentence.
protected  ArrayList list
          A list of all the constraints in this set, for making iteration easy.
protected  UnlexTreeConstraint root
          The root of this tree of constraints.
protected  int size
          The number of constraints in this set.
 
Constructor Summary
UnlexTreeConstraintSet()
          Constructs an empty set of constraints.
UnlexTreeConstraintSet(Sexp tree)
          Constructs a constraint set derived from the specified unlexicalized syntactic tree.
 
Method Summary
protected  void buildConstraintSet(Sexp tree)
          Builds the constraint tree from the specified unlexicalized parse tree.
protected  void collectNodes(UnlexTreeConstraint tree)
          A helper method to collect all of the constraints in the specified cosntraint tree.
 Constraint constraintSatisfying(Item item)
          Returns the first constraint in this set that is found that the specified item satisfies.
 boolean findAtLeastOneSatisfying()
          Returns true, since a satisfying constraint must be found for every chart item.
 boolean findNoViolations()
          Returns false, since this type of constraint set guarantees consistency among its constraints, meaning that, since every chart item must have an assigned, satisfying constraint, there cannot be any constraint violations, and therefore no such violation-checking needs to occur during decoding.
 boolean hasTreeStructure()
          Returns true, since this type of constraint set does, indeed, have a tree structure.
 boolean isViolatedBy(Item item)
          Simply throws an UnsupportedOperationException, since violations do not need to be checked for this type of constraint set.
 Iterator iterator()
          Returns an iterator over the constraints in this set.
 List leaves()
          Returns the leaves of the constraint tree contained by this object.
static void main(String[] args)
          Test driver for this class.
 Constraint root()
          Returns the root of the constraint tree contained by this object.
 int size()
          Returns the number of constraints in this constraint set.
 String toString()
          Returns a string representation of the constraint tree encapsulated by this constraint set object.
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

root

protected UnlexTreeConstraint root
The root of this tree of constraints.


size

protected int size
The number of constraints in this set.


list

protected ArrayList list
A list of all the constraints in this set, for making iteration easy.


leaves

protected ArrayList leaves
The leaves of this tree of constraints in their correct order as they correspond to single words (technically, preterminals) of a sentence.

Constructor Detail

UnlexTreeConstraintSet

public UnlexTreeConstraintSet()
Constructs an empty set of constraints.


UnlexTreeConstraintSet

public UnlexTreeConstraintSet(Sexp tree)
Constructs a constraint set derived from the specified unlexicalized syntactic tree.

Parameters:
tree - the unlexicalized syntactic tree from which to construct a set of constraints
Method Detail

buildConstraintSet

protected void buildConstraintSet(Sexp tree)
Builds the constraint tree from the specified unlexicalized parse tree. As a necessary side-effect, the root and leaves data members will be set/populated by this method.

Parameters:
tree - the tree from which to build this constraint set

collectNodes

protected void collectNodes(UnlexTreeConstraint tree)
A helper method to collect all of the constraints in the specified cosntraint tree.

Parameters:
tree - the root of a tree of constraints to be collected

hasTreeStructure

public boolean hasTreeStructure()
Returns true, since this type of constraint set does, indeed, have a tree structure.

Specified by:
hasTreeStructure in interface ConstraintSet
Returns:
true

findAtLeastOneSatisfying

public boolean findAtLeastOneSatisfying()
Returns true, since a satisfying constraint must be found for every chart item.

Specified by:
findAtLeastOneSatisfying in interface ConstraintSet
Returns:
true
See Also:
ConstraintSet.constraintSatisfying(Item)

findNoViolations

public boolean findNoViolations()
Returns false, since this type of constraint set guarantees consistency among its constraints, meaning that, since every chart item must have an assigned, satisfying constraint, there cannot be any constraint violations, and therefore no such violation-checking needs to occur during decoding.

Specified by:
findNoViolations in interface ConstraintSet
Returns:
false
See Also:
findAtLeastOneSatisfying()

root

public Constraint root()
Returns the root of the constraint tree contained by this object.

Specified by:
root in interface ConstraintSet
Returns:
the root of the constraint tree contained by this object
See Also:
ConstraintSet.hasTreeStructure()

leaves

public List leaves()
Returns the leaves of the constraint tree contained by this object.

Specified by:
leaves in interface ConstraintSet
Returns:
the leaves of the constraint tree contained by this object
See Also:
ConstraintSet.hasTreeStructure()

isViolatedBy

public boolean isViolatedBy(Item item)
Simply throws an UnsupportedOperationException, since violations do not need to be checked for this type of constraint set.

Specified by:
isViolatedBy in interface ConstraintSet
Parameters:
item - the item to be checked for violations
Returns:
true if the specified item violates a constraint in this set, false otherwise
See Also:
findNoViolations()

constraintSatisfying

public Constraint constraintSatisfying(Item item)
Description copied from interface: ConstraintSet
Returns the first constraint in this set that is found that the specified item satisfies.

Specified by:
constraintSatisfying in interface ConstraintSet
Parameters:
item - the item for which a satisfying constraint is to be found
Returns:
the first constraint in this set that is found that the specified item satisfies.

toString

public String toString()
Returns a string representation of the constraint tree encapsulated by this constraint set object.

Overrides:
toString in class AbstractCollection
Returns:
a string representation of the constraint tree encapsulated by this constraint set object

size

public int size()
Returns the number of constraints in this constraint set.

Specified by:
size in interface Collection
Specified by:
size in class AbstractCollection

iterator

public Iterator iterator()
Returns an iterator over the constraints in this set.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in class AbstractCollection
Returns:
an iterator over the constraints in this set

main

public static void main(String[] args)
Test driver for this class.

Parameters:
args -

Parsing Engine

Author: Dan Bikel.