edu.umn.cs.nlp.old
Class ParseSpan

java.lang.Object
  extended by edu.umn.cs.nlp.old.ParseSpan
All Implemented Interfaces:
Scorable, Equatable<ParseSpan>, Comparable<ParseSpan>

public class ParseSpan
extends Object
implements Scorable, Comparable<ParseSpan>, Equatable<ParseSpan>

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

Version:
$LastChangedDate: 2007-11-05 14:47:08 -0600 (Mon, 05 Nov 2007) $
Author:
Lane Schwartz

Field Summary
static String ELIDE_STAR
           
 
Constructor Summary
ParseSpan(int i, int j, LanguageModel languageModel, TranslationRule rule, ParseSpan... children)
          Construct a new chart cell that spans from i to j.
ParseSpan(int i, LanguageModel languageModel, TranslationRule rule)
           
ParseSpan(int i, String terminal)
          Construct a new chart cell that contains a terminal symbol.
 
Method Summary
 int compareTo(ParseSpan c)
           
 boolean equals(ParseSpan c)
           
 ParseSpan getChild(int index)
          Get the nth child cell pointed to by this cell.
 String getItem()
          Get the item stored in this chart cell.
 ParseSpan getOnlyChild()
          Get the first child cell pointed to by this cell.
 TranslationRule getRule()
           
 double getScore()
          Get the log probability associated with 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.
 LoglinearTranslationFeatures getWeights()
           
 int hashCode()
           
 boolean hasNoChildren()
          Returns true if this cell has no children, false otherwise
 boolean isTerminal()
           
static void main(String[] args)
           
 int numberOfChildren()
          Get the number of children of this cell
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ELIDE_STAR

public static final String ELIDE_STAR
See Also:
Constant Field Values
Constructor Detail

ParseSpan

public ParseSpan(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

ParseSpan

public ParseSpan(int i,
                 int j,
                 LanguageModel languageModel,
                 TranslationRule rule,
                 ParseSpan... 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

ParseSpan

public ParseSpan(int i,
                 LanguageModel languageModel,
                 TranslationRule rule)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

main

public static void main(String[] args)

getWeights

public LoglinearTranslationFeatures getWeights()

isTerminal

public boolean isTerminal()

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

getRule

public TranslationRule getRule()

getOnlyChild

public ParseSpan 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 ParseSpan 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

getScore

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

Specified by:
getScore in interface Scorable
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(ParseSpan c)
Specified by:
equals in interface Equatable<ParseSpan>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

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