|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdanbikel.parser.constraints.PartialTreeConstraint
public class PartialTreeConstraint
An implementation of a constraint to sit in a tree structure of constraints that represent a subgraph (certain brackets) of a tree, constraining a decoder to pursue only theories that contain the brackets of the constraint set of these objects.
Field Summary | |
---|---|
protected List |
children
All child constraints of this constraint. |
protected int |
end
The ending word index of the syntactic subtree covered by this constraint. |
protected boolean |
fullySatisfied
Contains whether this constraint has been fully satisfied. |
protected Symbol |
label
The nonterminal label associated with this constraint. |
protected Nonterminal |
nt
A Nonterminal object for use with
Treebank.parseNonterminal(Symbol,Nonterminal) . |
protected Nonterminal |
otherNT
A Nonterminal object for use with
Treebank.parseNonterminal(Symbol,Nonterminal) . |
protected PartialTreeConstraint |
parent
The parent constraint of this constraint. |
protected boolean |
satisfied
Contains whether this constraint has been partially satisfied. |
protected int |
start
The starting word index of the syntactic subtree covered by this constraint. |
Constructor Summary | |
---|---|
protected |
PartialTreeConstraint()
Constructs an empty constraint tree. |
protected |
PartialTreeConstraint(PartialTreeConstraint parent,
Sexp tree,
IntCounter currWordIdx)
A helper constructor for constructing a tree of constraints rooted at the specified subtree with the specified parent . |
|
PartialTreeConstraint(Sexp tree)
Constructs a tree of constraints rooted at the specified syntactic tree. |
Method Summary | |
---|---|
int |
end()
Returns the end index of the span associated with this constraint. |
protected List |
getChildren()
Returns the list of children of this constraint. |
Constraint |
getParent()
Returns the parent of this constraint if this constraint has been fullySatisfied ; otherwise, returns this constraint. |
boolean |
hasBeenSatisfied()
Returns whether this constraint has been partially satisfied. |
boolean |
isLeaf()
Returns whether this constraint corresponds to a preterminal in the original syntactic tree. |
boolean |
isLocallySatisfiedBy(Item item)
Returns whether the specified item's span does not exceed the bounds of the span associated with this constraint. |
boolean |
isSatisfiedBy(Item item)
Returns true if this constraint is satisfied by its local
information. |
protected boolean |
isSatisfiedByPreterminal(CKYItem item)
Returns true . |
boolean |
isViolatedBy(Item item)
Throws an UnsupportedOperationException , as this operation
is not appropriate for partial tree constraints. |
boolean |
isViolatedByChild(Item childItem)
Returns whether the specified child chart item violates this constraint by having a span beyond the boundaries of this constraint's span. |
Symbol |
label()
Returns the nonterminal label associated with this constraint. |
protected boolean |
labelMatches(Item item)
Returns whether this constraint's label subsumes the label of the specified item. |
protected boolean |
spanMatches(Item item)
Returns whether the start and end indices of the specified chart item are equal to the start and end indices, respectively, of the span associated with this constraint. |
protected boolean |
spanOK(Item item)
Returns whether the span of the specified item crosses the span. |
int |
start()
Returns the start index of the span associated with this constraint. |
Sexp |
toSexp()
Returns a symbolic expression representing the tree of constraints rooted at this constraint (intended for debugging purposes). |
String |
toString()
Returns a human-readable string representation of this constraint (intended for debugging purposes). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected PartialTreeConstraint parent
protected List children
protected Symbol label
protected Nonterminal nt
Nonterminal
object for use with
Treebank.parseNonterminal(Symbol,Nonterminal)
.
protected Nonterminal otherNT
Nonterminal
object for use with
Treebank.parseNonterminal(Symbol,Nonterminal)
.
protected int start
protected int end
protected boolean satisfied
protected boolean fullySatisfied
Constructor Detail |
---|
public PartialTreeConstraint(Sexp tree)
tree
- a possibly-underspecified syntactic tree representing nodes
and spans that must be produced by any derivation pursued by the
decoderprotected PartialTreeConstraint()
protected PartialTreeConstraint(PartialTreeConstraint parent, Sexp tree, IntCounter currWordIdx)
parent
.
parent
- the parent of the specified tree, or null
if the specified tree has no parenttree
- the tree for which to construct an isomorphic tree of
constraintscurrWordIdx
- the start index of the span covered by the specified
tree, threaded through the recursive calls to this constructorMethod Detail |
---|
public boolean isLeaf()
isLeaf
in interface Constraint
ConstraintSet.hasTreeStructure()
public boolean isViolatedByChild(Item childItem)
isViolatedByChild
in interface Constraint
childItem
- the child item to be tested
ConstraintSet.hasTreeStructure()
public Constraint getParent()
fullySatisfied
; otherwise, returns this constraint.
Implementation note: While this method does not always return the
parent constraint of this constraint, the semantics of this method are
appropriate for imposing partial tree constraints during a bottom-up
decoding process.
getParent
in interface Constraint
fullySatisfied
; otherwise, returns this constraint.ConstraintSet.hasTreeStructure()
protected List getChildren()
public Symbol label()
public int start()
public int end()
public boolean isViolatedBy(Item item)
UnsupportedOperationException
, as this operation
is not appropriate for partial tree constraints.
isViolatedBy
in interface Constraint
item
- the item to test
protected boolean isSatisfiedByPreterminal(CKYItem item)
true
.
item
- a preterminal derivation item
true
under all circumstancespublic boolean isSatisfiedBy(Item item)
true
if this constraint is satisfied by its local
information. Internally, this constraint is said to be fully
satisfied if all its child constraints are fully satisfied, and if the
specified item has a matching span and a matching label, as
determined by the spanMatches(Item)
and labelMatches(Item)
methods, respectively.
isSatisfiedBy
in interface Constraint
item
- the item to test for satisfaction by this constraint
isLocallySatisfiedBy(Item)
,
spanMatches(Item)
,
labelMatches(Item)
public boolean hasBeenSatisfied()
hasBeenSatisfied
in interface Constraint
satisfied
public boolean isLocallySatisfiedBy(Item item)
isLocallySatisfiedBy
in interface Constraint
item
- the chart item whose span is to be tested
protected boolean spanOK(Item item)
item
- the item whose span is to be tested
protected boolean spanMatches(Item item)
item
- the chart item whose span is to be compared to that associated
with this constraint
protected boolean labelMatches(Item item)
item
- the item whose label is to be tested
Nonterminal.subsumes(Nonterminal)
public Sexp toSexp()
toSexp
in interface SexpConvertible
public String toString()
toString
in class Object
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |