Parsing Engine

danbikel.parser
Class Item

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

public abstract class Item
extends Object
implements Serializable, Comparable

Skeletal class to represent items in a parsing chart. Items implement the comparable interface, so as to be sorted by their probability.

See Also:
Chart, Serialized Form

Field Summary
protected  double logProb
          The log-probability of this chart item.
 
Constructor Summary
protected Item()
          Constructs this item to have an initial log-probability of Constants.logOfZero.
protected Item(double logProb)
          Constructs a chart item with the specified log-probability score.
 
Method Summary
 Item clear()
          Clears data members of this item before reclamation (called by Chart.reclaimItem(Item)).
 int compareTo(Object o)
          Compares this item's log-probability score with that of the specified object, which must also be an instance of Item.
abstract  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).
abstract  Constraint getConstraint()
          Returns the constraint associated with this chart item, or null if this item has no associated constraint.
 void hasEquivalentItem(Item equivalentItem)
          Indicates that the specified item that was produced during decoding is equivalent to this item.
abstract  Object label()
          Returns the label of this chart item.
 double logProb()
          Gets the log probability of this chart item.
abstract  void setConstraint(Constraint constraint)
          Sets the constraint for this item.
abstract  void setGarbage(boolean garbage)
          Sets the value of this item's garbage status.
abstract  void setLabel(Object label)
          Sets the label of this chart item.
 void setLogProb(double logProb)
          Sets the log probability of this chart item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logProb

protected double logProb
The log-probability of this chart item.

Constructor Detail

Item

protected Item()
Constructs this item to have an initial log-probability of Constants.logOfZero. This constructor will be called, often implicitly, by the constructor of a subclass.

See Also:
Constants.logOfZero

Item

protected Item(double logProb)
Constructs a chart item with the specified log-probability score.

Parameters:
logProb - the log probability of this chart item, also known as its score
Method Detail

label

public abstract Object label()
Returns the label of this chart item.


setLabel

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


logProb

public double logProb()
Gets the log probability of this chart item.


setLogProb

public void setLogProb(double logProb)
Sets the log probability of this chart item.


garbage

public abstract 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).

See Also:
Chart.add(int,int,Item)

getConstraint

public abstract Constraint getConstraint()
Returns the constraint associated with this chart item, or null if this item has no associated constraint.


setConstraint

public abstract void setConstraint(Constraint constraint)
Sets the constraint for this item.

Parameters:
constraint - the constraint to be associated with this item.

setGarbage

public abstract void setGarbage(boolean garbage)
Sets the value of this item's garbage status.

See Also:
garbage(), Chart.add(int,int,Item)

hasEquivalentItem

public void hasEquivalentItem(Item equivalentItem)
Indicates that the specified item that was produced during decoding is equivalent to this item.

Parameters:
equivalentItem - a chart item equivalent to this one

clear

public Item clear()
Clears data members of this item before reclamation (called by Chart.reclaimItem(Item)). The default implementation here does nothing.

Returns:
the item being cleared (this item)

compareTo

public int compareTo(Object o)
Compares this item's log-probability score with that of the specified object, which must also be an instance of Item. Returns -1, 0 or 1, depending on whether this item's score is less than, equal to or greater than, respectively, the specified item's score. By implementing the Comparable interface, instances of Item may be used in collections and with algorithms in the Java Collections Framework that perform sorting.

Specified by:
compareTo in interface Comparable
Parameters:
o - the Item instance whose score is to be compared with the score of this item
Returns:
-1, 0 or 1, depending on whether this item's score is less than, equal to or greater than, respectively, the specified item's score
See Also:
logProb()

Parsing Engine

Author: Dan Bikel.