edu.umn.cs.nlp.parser
Class ChartCell

java.lang.Object
  extended by edu.umn.cs.nlp.parser.ChartCell
All Implemented Interfaces:
Equatable<ChartCell>, Comparable<ChartCell>

public class ChartCell
extends Object
implements Comparable<ChartCell>, Equatable<ChartCell>

Represents a completed span in a variant CKY+ parse chart. Rules are not required to be in Chomsky Normal Form.

Version:
$LastChangedDate: 2007-07-23 19:45:41 -0500 (Mon, 23 Jul 2007) $
Author:
Lane Schwartz

Constructor Summary
ChartCell(int i, int j, BasicRuleLHS lhs, ChartCell... children)
          Construct a new chart cell that spans from i to j.
ChartCell(int i, String terminal)
          Construct a new chart cell that contains a terminal symbol.
 
Method Summary
 int compareTo(ChartCell c)
           
 boolean equals(ChartCell c)
           
 ChartCell getChild(int index)
          Get the nth child cell pointed to by this cell.
 String getItem()
          Get the item stored in this chart cell.
 double getLogProb()
          Get the log probability associated with this cell
 ChartCell getOnlyChild()
          Get the first child cell pointed to by this cell.
 int getSpansFrom()
          Get the chart index from which this cell spans
 int getSpansTo()
          Get the chart index to which this cell spans
 int getSplitPoint(int index)
          Get the nth split point for this chart cell.
 int hashCode()
           
 boolean hasNoChildren()
          Returns true if this cell has no children, false otherwise
 int numberOfChildren()
          Get the number of children of this cell
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChartCell

public ChartCell(int i,
                 String terminal)
Construct a new chart cell that contains a terminal symbol. This cell will span from i to i+1.

Parameters:
i - start index from which this cell spans
terminal - item which this cell contains

ChartCell

public ChartCell(int i,
                 int j,
                 BasicRuleLHS lhs,
                 ChartCell... children)
Construct a new chart cell that spans from i to j. This chart cell will contain the item specified by lhs, and will point to the cells provided in children.

Parameters:
i - start index from which this cell spans
j - end index to which this cell spans
lhs - item which this cell contains
children - the cells pointed to by this cell
Method Detail

getItem

public String getItem()
Get the item stored in this chart cell. The item returned corresponds to the left-hand side of a grammar rule.

Returns:
the item stored in this chart cell

getOnlyChild

public ChartCell getOnlyChild()
Get the first child cell pointed to by this cell.

Note: this method is is intended for use with unary rule cells and terminal cells, but if called on a cell with more than one child, will return the same value as if getChild(0) had been called.

Returns:
the child cell

getChild

public ChartCell getChild(int index)
Get the nth child cell pointed to by this cell.

Parameters:
index - index of the child cell to be returned
Returns:
the child chart cell

hasNoChildren

public boolean hasNoChildren()
Returns true if this cell has no children, false otherwise

Returns:
true if this cell has no children, false otherwise

numberOfChildren

public int numberOfChildren()
Get the number of children of this cell

Returns:
the number of children of this cell

getLogProb

public double getLogProb()
Get the log probability associated with this cell

Returns:
the log probability associated with this cell

getSpansFrom

public int getSpansFrom()
Get the chart index from which this cell spans

Returns:
the chart index from which this cell spans

getSpansTo

public int getSpansTo()
Get the chart index to which this cell spans

Returns:
the chart index to which this cell spans

getSplitPoint

public int getSplitPoint(int index)
Get the nth split point for this chart cell. This is equivalent to calling getChild(index).getSpansTo()

Returns:
the chart index at which this split point occurs
Throws:
IllegalArgumentException - if index is greater than the number of split points for this cell

equals

public boolean equals(ChartCell c)
Specified by:
equals in interface Equatable<ChartCell>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(ChartCell c)
Specified by:
compareTo in interface Comparable<ChartCell>