Parsing Engine

danbikel.parser
Class CKYItem

java.lang.Object
  extended by danbikel.parser.Item
      extended by danbikel.parser.CKYItem
All Implemented Interfaces:
SexpConvertible, Serializable, Comparable
Direct Known Subclasses:
CKYItem.BaseNPAware, CKYItem.MappedPrevModBaseNPAware, CKYItem.PrevModIsStart

public class CKYItem
extends Item
implements SexpConvertible

An item in a CKYChart for use when parsing via a probabilistic version of the CKY algorithm.

See Also:
CKYChart, Serialized Form

Nested Class Summary
static class CKYItem.BaseNPAware
          A base NP–aware version of CKYItem that overrides CKYItem.BaseNPAware.equals(java.lang.Object) and CKYItem.BaseNPAware.hashCode() to take into account the lack of dependence on the distance metric when the root label of an item's set of derivations is NPB.
static class CKYItem.KBestHack
          A hack to approximate k-best parsing by effectively turning off dynamic programming (usability depends on reducing the beam size from its normal value).
static class CKYItem.MappedPrevModBaseNPAware
          Overrides equals and hashCode methods to compare the last previous modifier on each side of each chart item's head child with respect to their respective equivalence classes, as determined by the mapping provided by NTMapper.map(Symbol).
static class CKYItem.PrevModIsStart
          Overrides equals and hashCode methods to take the last previous modifier into account only insofar as its equality to the initial Training.startSym() modifier.
 
Field Summary
protected static boolean baseNPsCannotContainVerbs
          The value of the Settings.baseNPsCannotContainVerbs setting.
protected  Constraint constraint
          The constraint associated with this chart item.
protected  byte containsVerb
          The cached value of the result of the containsVerb() method invoked on this chart item, initially set to containsVerbUndefined.
protected static byte containsVerbFalse
          One of three possible cached values of this item's “contains verb” status, indicating that the method containsVerb() has been invoked on this item and its value is false (i.e., this item does not have a derivation dominating a verb).
protected static byte containsVerbTrue
          One of three possible cached values of this item's “contains verb” status, indicating that the method containsVerb() has been invoked on this item and its value is true (i.e., this item has a derivation dominating a verb).
protected static byte containsVerbUndefined
          One of three possible cached values of this item's “contains verb” status, indicating that the method containsVerb() has not yet been invoked on this item.
protected  int end
          The index of the last word of the span covered by this item.
protected  boolean garbage
          The boolean indicating whether this item has been eliminated from the chart because another, equivalent item was added (meaning that this item could not be immediately reclaimed, since the caller of Chart.add may have a handle onto this item).
protected  CKYItem headChild
          The item representing the head child of the tree node represented by this chart item, or null if this item represents a preterminal.
protected  Word headWord
          The head word of this chart item.
protected  Symbol label
          The label of this chart item.
protected  SLNode leftChildren
          A list of CKYItem objects that are the children to the left of the head child, with the head-adjacent child being last.
protected  SexpList leftPrevMods
          The previous modifiers generated on the left of the head child.
protected  Subcat leftSubcat
          The subcat frame representing the unmet requirements on the left side of the head as of the production of this chart item.
protected  boolean leftVerb
          The boolean indicating whether a verb intervenes between the head child and the currently-generated left-modifying child.
protected  double logPrior
          The log of the probability of the lexicalized root nonterminal label of the tree represented by this item.
protected  double logTreeProb
          The log of the probability of the tree represented by this item.
protected static char nonTreebankDelimiter
          The value of Treebank.nonTreebankDelimiter().
protected static char nonTreebankLeftBracket
          The value of Treebank.nonTreebankLeftBracket().
protected static char nonTreebankRightBracket
          The value of Treebank.nonTreebankRightBracket().
protected  int numParses
          The total number of possible parses represented by this chart item.
protected static int numPrevMods
          The value of the property Settings.numPrevMods, cached here for efficiency and convenience.
protected static int numPrevWords
          The value of the property Settings.numPrevWords, cached here for efficiency and convenience.
protected static boolean outputInsideProbs
          The value of the Settings.decoderOutputInsideProbs setting.
protected static boolean outputLexLabels
          The value of the Settings.decoderOutputHeadLexicalizedLabels setting.
protected  SLNode rightChildren
          A list of CKYItem objects that are the children to the right of the head child, with the head-adjacent child being last.
protected  SexpList rightPrevMods
          The previous modifiers generated on the right of the head child.
protected  Subcat rightSubcat
          The subcat frame representing the unmet requirements on the right side of the head as of the production of this chart item.
protected  boolean rightVerb
          The boolean indicating whether a verb intervenes between the head child and the currently-generated right-modifying child.
protected  int start
          The index of the first word of the span covered by this item.
protected  boolean stop
          The boolean indicating whether this item has received its stop probabilities.
protected static Word stopWord
          The value of Training.stopWord(), cached here for efficiency and convenience.
protected static Symbol topSym
          The value of Training.topSym(), cached for efficiency and convenience.
 
Fields inherited from class danbikel.parser.Item
logProb
 
Constructor Summary
CKYItem()
          Default constructor.
CKYItem(Symbol label, Word headWord, Subcat leftSubcat, Subcat rightSubcat, CKYItem headChild, SLNode leftChildren, SLNode rightChildren, SexpList leftPrevMods, SexpList rightPrevMods, int start, int end, boolean leftVerb, boolean rightVerb, boolean stop, double logTreeProb, double logPrior, double logProb)
          Constructs a CKY chart item with the specified data.
 
Method Summary
 SLNode children(boolean side)
          Returns the modifier (children) list of the specified side of this item's head child, or null if the specified side has no modifiers.
 Item clear()
          Sets the number of parses represented by this chart item to 1.
 boolean containsVerb()
          Returns whether a verb has been generated anywhere in the surface string in the set of derivations of this chart item.
protected  boolean containsVerbRecursive()
          A helper method for containsVerb() that returns whether a verb has been generated anywhere in the surface string of the derivations of this chart item.
 int edgeIndex(boolean side)
          Returns the value of start() if the specified side is Constants.LEFT or the value of end() otherwise.
 int end()
          Returns the end word index of the span of this chart item.
 boolean equals(Object obj)
          Returns true if and only if the specified object is also an instance of a CKYItem and all elements of this CKYItem are equal to those of the specified CKYItem, except their left and right children lists and their log probability values.
 boolean garbage()
          Returns whether this item has been eliminated from the chart because another, equivalent item was added (meaning that this item could not be immediately reclaimed, since the caller of Chart.add may have a handle onto this item).
 Constraint getConstraint()
          Returns the constraint associated with this chart item, or null if this item has no associated constraint.
protected  Symbol getLabel(Symbol label, boolean isHeadChild)
          Helper method used by toSexpInternal(boolean), to provide a layer of abstraction so that the label can include, e.g., head information.
 void hasAntecedent(Item antecedent)
          Indicates that the specified item is an antecedent to this item, allowing a subclass instance to store a list of antecedents, or do other computation based on its antecedents.
 void hasEquivalentItem(Item equivalentItem)
          Indicates that the specified item is equivalent to this item, allowing a subclass to do arbitrary computation when the decoder produces such an item (this method is guaranteed to be called by the decoder when that happens).
 int hashCode()
          Computes the hash code based on all elements used by the equals(java.lang.Object) method.
 CKYItem headChild()
          Returns the head child item of this item.
 Symbol headLabel()
          Returns the root nonterminal label of the derivation of this item's head child.
 Word headWord()
          Returns the head word of this chart item.
 int headWordIdx()
          Recursively computes the index of the head word of this derivation.
 boolean isPreterminal()
          Returns true if this item represents a preterminal.
 Object label()
          Returns the symbol that is the label of this chart item.
 SLNode leftChildren()
          Returns the left modifier item list of this item, or null if there are no left modifier items.
 SexpList leftPrevMods()
          Returns a list of previously-generated unlexicalized modifiers on the left side of the head child in this item's set of derivations.
 Subcat leftSubcat()
          Returns the left subcat of this chart item.
 boolean leftVerb()
          Returns whether a verb has been generated anywhere in the surface strings of the left modifiers of the head child.
 double logPrior()
          Returns the marginal probability of generating the lexicalized root label of this item's set of derivations (strictly speaking, this is not a “prior” as the name of this method would suggest).
 double logProb()
          Returns the log probability, or score, of this chart item.
 double logTreeProb()
          Returns the probability of generating all the children of this chart item (head child and left and right modifier children).
 int numLeftChildren()
          Returns the number of children in the left modifier item list.
 int numParses()
          The total number of possible parses represented by this chart item.
 int numRightChildren()
          Returns the number of children in the right modifier item list.
 SexpList prevMods(boolean side)
          Returns the previous modifiers on the specified side of this item's head child.
protected  boolean prevWordsEqual(boolean side, CKYItem other)
          Returns whether the head words of modifier children on the specified side of this item are equal to those on the specified side of the specified other item.
protected  boolean prevWordsEqual(CKYItem other)
          Returns whether the previous word lists of this chart item are equal to those of the specified item.
 SLNode rightChildren()
          Returns the right modifier item list of this item, or null if there are no right modifier items.
 SexpList rightPrevMods()
          Returns a list of previously-generated unlexicalized modifiers on the right side of the head child in this item's set of derivations.
 Subcat rightSubcat()
          Returns the right subcat of this chart item.
 boolean rightVerb()
          Returns whether a verb has been generated anywhere in the surface strings of the right modifiers of the head child.
 void set(Symbol label, Word headWord, Subcat leftSubcat, Subcat rightSubcat, CKYItem headChild, SLNode leftChildren, SLNode rightChildren, SexpList leftPrevMods, SexpList rightPrevMods, int start, int end, boolean leftVerb, boolean rightVerb, boolean stop, double logTreeProb, double logPrior, double logProb)
          Sets all of the data members of this chart item.
 void setChildren(boolean side, SLNode children)
          Sets the modifier (children) list on the specified side of this chart item.
 void setConstraint(Constraint constraint)
          Sets the constraint for this item.
 CKYItem setDataFrom(CKYItem other)
          Assigns data members of specified CKYItem to this item, effectively performing a destructive shallow copy of the specified item into this item.
 void setEdgeIndex(boolean side, int index)
          Sets the index of the leftmost or rightmost word spanned by this chart item.
 void setGarbage(boolean garbage)
          Sets whether this item has been eliminated from the chart because another, equivalent item was added (meaning that this item could not be immediately reclaimed, since the caller of Chart.add may have a handle onto this item).
 void setLabel(Object label)
          Sets the label of this chart item.
 void setLeftSubcat(Subcat leftSubcat)
          Sets the left subcat of this chart item to the specified value.
 void setLogPrior(double logPrior)
          Sets the log of the marginal probability of the lexicalized root nonterminal label of this chart item to the specified value.
 void setLogProb(double logProb)
          Sets the log of the probability of this chart item (its score) to the specified value.
 void setLogTreeProb(double logTreeProb)
          Sets the log of the probability of generating all of this item's children to the specified value.
 void setPrevMods(boolean side, SexpList prevMods)
          Sets the previous modifier list on the specified side of this chart item's head child.
 void setRightSubcat(Subcat rightSubcat)
          Sets the right subcat of this chart item to the specified value.
 void setSideInfo(boolean side, Subcat subcat, SLNode children, SexpList prevMods, int edgeIndex, boolean verb)
          Sets all the side-specific information for one side of this chart item.
 void setSubcat(boolean side, Subcat subcat)
          Sets the subcat on the specified side of this chart item's head child.
 void setVerb(boolean side, boolean verb)
          Sets whether a verb has been generated anywhere in the surface string on the specified side of this item's head child.
protected static String shortBool(boolean bool)
          Returns the string "t" if the specified boolean is true and the string "f" if the specified boolean is false.
protected static String shortContainsVerb(byte containsVerbValue)
          Returns the string "undef" if the cached value of this item's “contains verb” status is containsVerbUndefined; otherwise, returns the string that would result in executing shortBool(containsVerb()).
 int start()
          Returns the start word index of the span of this chart item.
 boolean stop()
          Returns whether this item has received its stop probabilities.
 Subcat subcat(boolean side)
          Returns the subcat on the specified side of this item's head child.
 Sexp toSexp()
          Returns the S-expression representation of the tree rooted at this chart item.
protected  Sexp toSexpInternal(boolean isHeadChild)
          Returns the S-expression representation of the tree rooted at this chart item (helper method invoked by toSexp()).
 String toString()
          Returns a string containing all the information contained locally in this chart item (for debugging purposes).
 boolean verb(boolean side)
          Returns whether a verb has been generated anywhere in the surface string on the specified side of this item's head child.
 
Methods inherited from class danbikel.parser.Item
compareTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

outputLexLabels

protected static boolean outputLexLabels
The value of the Settings.decoderOutputHeadLexicalizedLabels setting.


outputInsideProbs

protected static boolean outputInsideProbs
The value of the Settings.decoderOutputInsideProbs setting.


nonTreebankLeftBracket

protected static char nonTreebankLeftBracket
The value of Treebank.nonTreebankLeftBracket().


nonTreebankRightBracket

protected static char nonTreebankRightBracket
The value of Treebank.nonTreebankRightBracket().


nonTreebankDelimiter

protected static char nonTreebankDelimiter
The value of Treebank.nonTreebankDelimiter().


baseNPsCannotContainVerbs

protected static boolean baseNPsCannotContainVerbs
The value of the Settings.baseNPsCannotContainVerbs setting.


topSym

protected static Symbol topSym
The value of Training.topSym(), cached for efficiency and convenience.


stopWord

protected static Word stopWord
The value of Training.stopWord(), cached here for efficiency and convenience.


numPrevMods

protected static int numPrevMods
The value of the property Settings.numPrevMods, cached here for efficiency and convenience.


numPrevWords

protected static int numPrevWords
The value of the property Settings.numPrevWords, cached here for efficiency and convenience.


containsVerbUndefined

protected static final byte containsVerbUndefined
One of three possible cached values of this item's “contains verb” status, indicating that the method containsVerb() has not yet been invoked on this item.

See Also:
Constant Field Values

containsVerbTrue

protected static final byte containsVerbTrue
One of three possible cached values of this item's “contains verb” status, indicating that the method containsVerb() has been invoked on this item and its value is true (i.e., this item has a derivation dominating a verb).

See Also:
Constant Field Values

containsVerbFalse

protected static final byte containsVerbFalse
One of three possible cached values of this item's “contains verb” status, indicating that the method containsVerb() has been invoked on this item and its value is false (i.e., this item does not have a derivation dominating a verb).

See Also:
Constant Field Values

logTreeProb

protected double logTreeProb
The log of the probability of the tree represented by this item.


logPrior

protected double logPrior
The log of the probability of the lexicalized root nonterminal label of the tree represented by this item.


label

protected Symbol label
The label of this chart item.


headWord

protected Word headWord
The head word of this chart item.


leftSubcat

protected Subcat leftSubcat
The subcat frame representing the unmet requirements on the left side of the head as of the production of this chart item.


rightSubcat

protected Subcat rightSubcat
The subcat frame representing the unmet requirements on the right side of the head as of the production of this chart item.


headChild

protected CKYItem headChild
The item representing the head child of the tree node represented by this chart item, or null if this item represents a preterminal.


leftChildren

protected SLNode leftChildren
A list of CKYItem objects that are the children to the left of the head child, with the head-adjacent child being last.


rightChildren

protected SLNode rightChildren
A list of CKYItem objects that are the children to the right of the head child, with the head-adjacent child being last.


leftPrevMods

protected SexpList leftPrevMods
The previous modifiers generated on the left of the head child.


rightPrevMods

protected SexpList rightPrevMods
The previous modifiers generated on the right of the head child.


start

protected int start
The index of the first word of the span covered by this item.


end

protected int end
The index of the last word of the span covered by this item.


constraint

protected Constraint constraint
The constraint associated with this chart item.


numParses

protected int numParses
The total number of possible parses represented by this chart item.


leftVerb

protected boolean leftVerb
The boolean indicating whether a verb intervenes between the head child and the currently-generated left-modifying child.


rightVerb

protected boolean rightVerb
The boolean indicating whether a verb intervenes between the head child and the currently-generated right-modifying child.


stop

protected boolean stop
The boolean indicating whether this item has received its stop probabilities.


garbage

protected boolean garbage
The boolean indicating whether this item has been eliminated from the chart because another, equivalent item was added (meaning that this item could not be immediately reclaimed, since the caller of Chart.add may have a handle onto this item).


containsVerb

protected byte containsVerb
The cached value of the result of the containsVerb() method invoked on this chart item, initially set to containsVerbUndefined.

Constructor Detail

CKYItem

public CKYItem()
Default constructor. Data members set to default values.


CKYItem

public CKYItem(Symbol label,
               Word headWord,
               Subcat leftSubcat,
               Subcat rightSubcat,
               CKYItem headChild,
               SLNode leftChildren,
               SLNode rightChildren,
               SexpList leftPrevMods,
               SexpList rightPrevMods,
               int start,
               int end,
               boolean leftVerb,
               boolean rightVerb,
               boolean stop,
               double logTreeProb,
               double logPrior,
               double logProb)
Constructs a CKY chart item with the specified data.

Parameters:
label - the unlexicalized root label of this chart item
headWord - the head word of this chart item
leftSubcat - the subcat on the left side of this item's head child
rightSubcat - the subcat on the right side of this item's head child
headChild - the head child item of this chart item
leftChildren - the modifiers on the left side of this item's head child
rightChildren - the modifiers on the right side of this item's head child
leftPrevMods - a list of the previous modifiers on the left side of this item's head child
rightPrevMods - a list of the previous modifiers on the right side of this item's head child
start - the index of the first word spanned by this item
end - the index of the last word spanned by this item
leftVerb - whether a verb has been generated anywhere in the surface string of the modifiers on the left side of this item's head child
rightVerb - whether a verb has been generated anywhere in the surface string of the modifiers on the right side of this item's head child
stop - whether this item has received its stop probabilities
logTreeProb - the log of the probability of generating all of this item's child items (head child and left and right modifier children)
logPrior - the log of the marginal probability of this item's lexicalized root label
logProb - the log of the probability of this chart item (its score)
Method Detail

set

public void set(Symbol label,
                Word headWord,
                Subcat leftSubcat,
                Subcat rightSubcat,
                CKYItem headChild,
                SLNode leftChildren,
                SLNode rightChildren,
                SexpList leftPrevMods,
                SexpList rightPrevMods,
                int start,
                int end,
                boolean leftVerb,
                boolean rightVerb,
                boolean stop,
                double logTreeProb,
                double logPrior,
                double logProb)
Sets all of the data members of this chart item.

Parameters:
label - the unlexicalized root label of this chart item
headWord - the head word of this chart item
leftSubcat - the subcat on the left side of this item's head child
rightSubcat - the subcat on the right side of this item's head child
headChild - the head child item of this chart item
leftChildren - the modifiers on the left side of this item's head child
rightChildren - the modifiers on the right side of this item's head child
leftPrevMods - a list of the previous modifiers on the left side of this item's head child
rightPrevMods - a list of the previous modifiers on the right side of this item's head child
start - the index of the first word spanned by this item
end - the index of the last word spanned by this item
leftVerb - whether a verb has been generated anywhere in the surface string of the modifiers on the left side of this item's head child
rightVerb - whether a verb has been generated anywhere in the surface string of the modifiers on the right side of this item's head child
stop - whether this item has received its stop probabilities
logTreeProb - the log of the probability of generating all of this item's child items (head child and left and right modifier children)
logPrior - the log of the marginal probability of this item's lexicalized root label
logProb - the log of the probability of this chart item (its score)

getConstraint

public Constraint getConstraint()
Description copied from class: Item
Returns the constraint associated with this chart item, or null if this item has no associated constraint.

Specified by:
getConstraint in class Item

setConstraint

public void setConstraint(Constraint constraint)
Description copied from class: Item
Sets the constraint for this item.

Specified by:
setConstraint in class Item
Parameters:
constraint - the constraint to be associated with this item.

label

public Object label()
Returns the symbol that is the label of this chart item.

Specified by:
label in class Item

headWord

public Word headWord()
Returns the head word of this chart item.


leftSubcat

public Subcat leftSubcat()
Returns the left subcat of this chart item.


rightSubcat

public Subcat rightSubcat()
Returns the right subcat of this chart item.


headChild

public CKYItem headChild()
Returns the head child item of this item.


leftChildren

public SLNode leftChildren()
Returns the left modifier item list of this item, or null if there are no left modifier items.


numLeftChildren

public int numLeftChildren()
Returns the number of children in the left modifier item list.


rightChildren

public SLNode rightChildren()
Returns the right modifier item list of this item, or null if there are no right modifier items.


numRightChildren

public int numRightChildren()
Returns the number of children in the right modifier item list.


leftPrevMods

public SexpList leftPrevMods()
Returns a list of previously-generated unlexicalized modifiers on the left side of the head child in this item's set of derivations. The list will be of length equal to the value of Settings.numPrevMods.

See Also:
Settings.numPrevMods

rightPrevMods

public SexpList rightPrevMods()
Returns a list of previously-generated unlexicalized modifiers on the right side of the head child in this item's set of derivations. The list will be of length equal to the value of Settings.numPrevMods.

See Also:
Settings.numPrevMods

start

public int start()
Returns the start word index of the span of this chart item. Note that the number of words spanned by this item is (end() - start()) + 1.

Returns:
the start word index of the span of this chart item.

end

public int end()
Returns the end word index of the span of this chart item. Note that the number of words spanned by this item is (end() - start()) + 1.

Returns:
the end word index of the span of this chart item.

headWordIdx

public int headWordIdx()
Recursively computes the index of the head word of this derivation.

Implementation advice: Because chart items do not store or cache the index returned by this method, it should be used only for debugging.

Returns:
the index of the head word of this derivation

leftVerb

public boolean leftVerb()
Returns whether a verb has been generated anywhere in the surface strings of the left modifiers of the head child.

Returns:
whether a verb has been generated anywhere in the surface strings of the left modifiers of the head child.

rightVerb

public boolean rightVerb()
Returns whether a verb has been generated anywhere in the surface strings of the right modifiers of the head child.

Returns:
whether a verb has been generated anywhere in the surface strings of the right modifiers of the head child.

stop

public boolean stop()
Returns whether this item has received its stop probabilities.

Returns:
whether this item has received its stop probabilities.
See Also:
Training.stopSym()

logProb

public double logProb()
Returns the log probability, or score, of this chart item. This is equal to logTreeProb() + logPrior().

Overrides:
logProb in class Item
Returns:
the log probability, or score, of this chart item.
See Also:
logTreeProb(), logPrior()

logTreeProb

public double logTreeProb()
Returns the probability of generating all the children of this chart item (head child and left and right modifier children).

Returns:
the probability of generating all the children of this chart item (head child and left and right modifier children).
See Also:
logProb(), logPrior()

logPrior

public double logPrior()
Returns the marginal probability of generating the lexicalized root label of this item's set of derivations (strictly speaking, this is not a “prior” as the name of this method would suggest).

Returns:
the marginal probability of generating the lexicalized root label of this item's set of derivations
See Also:
logProb(), logTreeProb()

headLabel

public Symbol headLabel()
Returns the root nonterminal label of the derivation of this item's head child.

Returns:
the root nonterminal label of the derivation of this item's head child.

garbage

public boolean garbage()
Returns whether this item has been eliminated from the chart because another, equivalent item was added (meaning that this item could not be immediately reclaimed, since the caller of Chart.add may have a handle onto this item).

Specified by:
garbage in class Item
See Also:
Chart.add(int,int,Item)

numParses

public int numParses()
The total number of possible parses represented by this chart item.


subcat

public Subcat subcat(boolean side)
Returns the subcat on the specified side of this item's head child.

Parameters:
side - the side whose subcat is to be gotten
Returns:
the subcat on the specified side of this item's head child.

children

public SLNode children(boolean side)
Returns the modifier (children) list of the specified side of this item's head child, or null if the specified side has no modifiers.

Parameters:
side - the side whose children list is to be gotten
Returns:
the modifier (children) list of the specified side of this item's head child, or null if the specified side has no modifiers.

prevMods

public SexpList prevMods(boolean side)
Returns the previous modifiers on the specified side of this item's head child.

Parameters:
side - the side whose previous modifier list is to be gotten
Returns:
the previous modifiers on the specified side of this item's head child.

verb

public boolean verb(boolean side)
Returns whether a verb has been generated anywhere in the surface string on the specified side of this item's head child.

Parameters:
side - the side of this item's head child to be tested
Returns:
whether a verb has been generated anywhere in the surface string on the specified side of this item's head child.

containsVerb

public boolean containsVerb()
Returns whether a verb has been generated anywhere in the surface string in the set of derivations of this chart item.

Implementation note: The return value of this method is cached locally in this chart item.

Returns:
whether a verb has been generated anywhere in the surface string in the set of derivations of this chart item.

containsVerbRecursive

protected boolean containsVerbRecursive()
A helper method for containsVerb() that returns whether a verb has been generated anywhere in the surface string of the derivations of this chart item.

Returns:
whether a verb has been generated anywhere in the surface string of the derivations of this chart item.
See Also:
Settings.baseNPsCannotContainVerbs

edgeIndex

public int edgeIndex(boolean side)
Returns the value of start() if the specified side is Constants.LEFT or the value of end() otherwise.

Parameters:
side - the side of the span whose index is to be gotten
Returns:
the value of start() if the specified side is Constants.LEFT or the value of end() otherwise.

setLabel

public void setLabel(Object label)
Sets the label of this chart item.

Specified by:
setLabel in class Item
Parameters:
label - a Symbol object that is to be the label of this chart item
Throws:
ClassCastException - if label is not an instance of Symbol

setLeftSubcat

public void setLeftSubcat(Subcat leftSubcat)
Sets the left subcat of this chart item to the specified value.

Parameters:
leftSubcat - the left subcat to be set for this chart item

setRightSubcat

public void setRightSubcat(Subcat rightSubcat)
Sets the right subcat of this chart item to the specified value.

Parameters:
rightSubcat - the right subcat to be set for this chart item

setLogTreeProb

public void setLogTreeProb(double logTreeProb)
Sets the log of the probability of generating all of this item's children to the specified value.

Parameters:
logTreeProb - the log of the probability of generating all of this item's children the log of the probability of generating all of this item's children
See Also:
logTreeProb()

setLogProb

public void setLogProb(double logProb)
Sets the log of the probability of this chart item (its score) to the specified value.

Overrides:
setLogProb in class Item
Parameters:
logProb - the log of the probability of this chart item (its score)
See Also:
logProb()

setLogPrior

public void setLogPrior(double logPrior)
Sets the log of the marginal probability of the lexicalized root nonterminal label of this chart item to the specified value.

Parameters:
logPrior - the log of the marginal probability of the lexicalized root nonterminal label of this chart item
See Also:
logPrior()

setSubcat

public void setSubcat(boolean side,
                      Subcat subcat)
Sets the subcat on the specified side of this chart item's head child.

Parameters:
side - the side of this chart item's head child on which to set the subcat, either Constants.LEFT or Constants.RIGHT
subcat - the subcat to set on the specified side of this item's head child

setChildren

public void setChildren(boolean side,
                        SLNode children)
Sets the modifier (children) list on the specified side of this chart item.

Parameters:
side - the side of this item's head child on which to set the modifier list, either Constants.LEFT or Constants.RIGHT
children - the modifier list to set for this item

setPrevMods

public void setPrevMods(boolean side,
                        SexpList prevMods)
Sets the previous modifier list on the specified side of this chart item's head child.

Parameters:
side - the side of this chart item's head child on which to set the previous modifier list, either Constants.LEFT or Constants.RIGHT
prevMods - the list of previous modifiers to set on the specified side of this chart item's head child

setEdgeIndex

public void setEdgeIndex(boolean side,
                         int index)
Sets the index of the leftmost or rightmost word spanned by this chart item.

Parameters:
side - the side of the span whose index is to be set, either Constants.LEFT or Constants.RIGHT
index - the index to be set on the specified side
See Also:
start(), end()

setVerb

public void setVerb(boolean side,
                    boolean verb)
Sets whether a verb has been generated anywhere in the surface string on the specified side of this item's head child.

Parameters:
side - the side on whose verb-generated value is to be set, either Constants.LEFT or Constants.RIGHT
verb - whether a verb has been generated anywhere in the surface string on the specified side of this item's head child

setSideInfo

public void setSideInfo(boolean side,
                        Subcat subcat,
                        SLNode children,
                        SexpList prevMods,
                        int edgeIndex,
                        boolean verb)
Sets all the side-specific information for one side of this chart item. This method is a synonym for executing the following code:
 setSubcat(side, subcat);
 setChildren(side, children);
 setPrevMods(side, prevMods);
 setEdgeIndex(side, edgeIndex);
 setVerb(side, verb);
 

Parameters:
side - the side of this item's head child on which to set informatioon for this chart item, either Constants.LEFT or Constants.RIGHT
subcat - the subcat to be set on the specified side of this item's head child
children - the children list to be set on the specified side of this item's head child
prevMods - the previous modifier list to be set on the specified side of this item's head child
edgeIndex - the edge index of the span of this item for either the leftmost or rightmost side
verb - whether a verb has been generated anywhere in the surface string on the specified side of this item's head child

setGarbage

public void setGarbage(boolean garbage)
Sets whether this item has been eliminated from the chart because another, equivalent item was added (meaning that this item could not be immediately reclaimed, since the caller of Chart.add may have a handle onto this item).

Specified by:
setGarbage in class Item
See Also:
Item.garbage(), Chart.add(int,int,Item)

hasAntecedent

public void hasAntecedent(Item antecedent)
Indicates that the specified item is an antecedent to this item, allowing a subclass instance to store a list of antecedents, or do other computation based on its antecedents. The default implementation here multiplies the numParses data member of this item by the number of parses of the specified antecedent.

Parameters:
antecedent - an antecedent of this item

hasEquivalentItem

public void hasEquivalentItem(Item equivalentItem)
Indicates that the specified item is equivalent to this item, allowing a subclass to do arbitrary computation when the decoder produces such an item (this method is guaranteed to be called by the decoder when that happens). The default implementation here simply adds the number of parses contained in the specified item to the number of parses contained in the derivation set of this item.

Overrides:
hasEquivalentItem in class Item
Parameters:
equivalentItem - the item that is equivalent to this item

isPreterminal

public boolean isPreterminal()
Returns true if this item represents a preterminal.


equals

public boolean equals(Object obj)
Returns true if and only if the specified object is also an instance of a CKYItem and all elements of this CKYItem are equal to those of the specified CKYItem, except their left and right children lists and their log probability values.

Overrides:
equals in class Object

prevWordsEqual

protected boolean prevWordsEqual(CKYItem other)
Returns whether the previous word lists of this chart item are equal to those of the specified item. This method is a synonym for
 return prevWordsEqual(Constants.LEFT, other) &&
        prevWordsEqual(Constants.RIGHT, other);
 

Parameters:
other - the chart item whose previous word lists are to be compared to this item's
Returns:
whether the previous word lists of this chart item are equal to those of the specified item.
See Also:
prevWordsEqual(boolean, CKYItem)

prevWordsEqual

protected boolean prevWordsEqual(boolean side,
                                 CKYItem other)
Returns whether the head words of modifier children on the specified side of this item are equal to those on the specified side of the specified other item.
Implementation note: This complicated method would not be necessary if we stored appropriate WordList objects within chart items (where "appropriate" means "created by the decoder using the Shifter to skip items that need to be skipped").

Parameters:
side - the side on which to compare head words of modifier children
other - the other chart item with which to compare modifier head words
Returns:
whether the previously-generated head words of modifier items of this chart item are equal to those of the specified other chart item

hashCode

public int hashCode()
Computes the hash code based on all elements used by the equals(java.lang.Object) method.

Overrides:
hashCode in class Object

toSexp

public Sexp toSexp()
Returns the S-expression representation of the tree rooted at this chart item.

Specified by:
toSexp in interface SexpConvertible
Returns:
the S-expression representation of the tree rooted at this chart item.
See Also:
toSexpInternal(boolean)

toSexpInternal

protected Sexp toSexpInternal(boolean isHeadChild)
Returns the S-expression representation of the tree rooted at this chart item (helper method invoked by toSexp()).

Parameters:
isHeadChild - indicates whether the caller of this method is the head child of its parent
Returns:
the S-expression representation of the tree rooted at this chart item.
See Also:
outputLexLabels, outputInsideProbs

getLabel

protected Symbol getLabel(Symbol label,
                          boolean isHeadChild)
Helper method used by toSexpInternal(boolean), to provide a layer of abstraction so that the label can include, e.g., head information.

Returns:
the (possibly head-lexicalized) root label of the derivation of this item
See Also:
outputLexLabels, outputInsideProbs

toString

public String toString()
Returns a string containing all the information contained locally in this chart item (for debugging purposes).

Overrides:
toString in class Object
Returns:
a string containing all the information contained locally in this chart item (for debugging purposes).

shortBool

protected static final String shortBool(boolean bool)
Returns the string "t" if the specified boolean is true and the string "f" if the specified boolean is false.

Parameters:
bool - the boolean to be converted to a short string
Returns:
the string "t" if the specified boolean is true and the string "f" if the specified boolean is false.

shortContainsVerb

protected static final String shortContainsVerb(byte containsVerbValue)
Returns the string "undef" if the cached value of this item's “contains verb” status is containsVerbUndefined; otherwise, returns the string that would result in executing shortBool(containsVerb()).

Parameters:
containsVerbValue -
Returns:
the string "undef" if the cached value of this item's “contains verb” status is containsVerbUndefined; otherwise, returns the value of shortBool(containsVerb()).

setDataFrom

public CKYItem setDataFrom(CKYItem other)
Assigns data members of specified CKYItem to this item, effectively performing a destructive shallow copy of the specified item into this item.

Parameters:
other - the item whose data members are to be assigned to this instance
Returns:
this item

clear

public Item clear()
Sets the number of parses represented by this chart item to 1.

Overrides:
clear in class Item
Returns:
this chart item

Parsing Engine

Author: Dan Bikel.