Parsing Engine

danbikel.parser.constraints
Interface ConstraintSet

All Superinterfaces:
Collection, Iterable
All Known Implementing Classes:
LexTreeConstraintSet, PartialLexTreeConstraintSet, PartialTreeConstraintSet, UnlexTreeConstraintSet

public interface ConstraintSet
extends Collection

Specifies methods for searching a set of parsing constraints either for satisfaction or violation of a particular chart item, as well as predicates describing properties of a constraint set and other methods to access various distinguished constraints in a set.

See Also:
Constraint, Item

Method Summary
 Constraint constraintSatisfying(Item item)
          Returns the first constraint in this set that is found that the specified item satisfies.
 boolean findAtLeastOneSatisfying()
          Returns true if at least one satisfying constraint should be found for every chart item, false otherwise.
 boolean findNoViolations()
          Returns true if every chart item generated must violate none of the constraints in this constraint set, false otherwise.
 boolean hasTreeStructure()
          Returns true if this constraint set forms a tree structure.
 boolean isViolatedBy(Item item)
          Returns whether this constraint set is violated by the specified item (optional operation).
 List leaves()
          Returns a list containing the leaves of a tree-structured set of constraints (optional operation).
 Constraint root()
          Returns the root constraint in a set if the set forms a tree structure (optional operation).
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

hasTreeStructure

boolean hasTreeStructure()
Returns true if this constraint set forms a tree structure. The return value of this method for an implementation of this interface informs the Decoder using this ConstraintSet that it can optimize constrain-parsing by tightly coupling it with its bottom-up decoding algorithm.

Returns:
true if this constraint set forms a tree structure.

findAtLeastOneSatisfying

boolean findAtLeastOneSatisfying()
Returns true if at least one satisfying constraint should be found for every chart item, false otherwise. If this method returns true, each chart item's satisfying constraint should be "attached" via its Item.setConstraint(Constraint) method.

Returns:
whether at least one satisfying constraint must be found per chart item generated
See Also:
constraintSatisfying(Item)

findNoViolations

boolean findNoViolations()
Returns true if every chart item generated must violate none of the constraints in this constraint set, false otherwise. Put procedurally, whenever a new chart item is generated, all constraints in this set must be checked for violations (although in practice, there may often be efficient ways to avoid an exhaustive search). This method should return false if an implementation inherently guarantees consistency among its constraints, thereby obviating the need for the decoder to check for violations for every chart item generated, as is the case, for example, with the UnlexTreeConstraintSet class.

Returns:
whether chart items need to violate none of the constraints in this set
See Also:
isViolatedBy(Item)

constraintSatisfying

Constraint constraintSatisfying(Item item)
Returns the first constraint in this set that is found that the specified item satisfies.

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.

isViolatedBy

boolean isViolatedBy(Item item)
Returns whether this constraint set is violated by the specified item (optional operation). It should usually be the case that this method returns true if there is at least one constraint in the set for which Constraint.isViolatedBy(Item) returns true, but such behavior is not required. For example, this method may return false simply because the specified item fails to satisfy certain constraints in this constraint set.

Parameters:
item - the item to be tested for violations
Returns:
true if this constraint set is violated by the specified item, false otherwise.

root

Constraint root()
Returns the root constraint in a set if the set forms a tree structure (optional operation).

Returns:
the root constraint in a set if the set forms a tree structure
See Also:
hasTreeStructure()

leaves

List leaves()
Returns a list containing the leaves of a tree-structured set of constraints (optional operation). Such constraint leaves would typically correspond to chart items representing words or preterminals.

Returns:
a list containing the leaves of a tree-structured set of constraints
See Also:
hasTreeStructure()

Parsing Engine

Author: Dan Bikel.