edu.umn.cs.nlp.mt.chiang2007
Class RuleApplication

java.lang.Object
  extended by edu.umn.cs.nlp.mt.huangchiang2005.Hyperarc<ChartCellEntry,Translation>
      extended by edu.umn.cs.nlp.mt.chiang2007.RuleApplication
All Implemented Interfaces:
Scorable, Comparable<RuleApplication>

public class RuleApplication
extends Hyperarc<ChartCellEntry,Translation>
implements Comparable<RuleApplication>, Scorable

Represents an application of a context-free rule in a CKY+ parse chart.

The k-best extraction technique used in Huang & Chiang (2005) requires that a parse chart be viewed as a hypergraph. In that context, a RuleApplication serves as a hyperarc in a hypergraph.

Version:
$LastChangedDate: 2007-11-14 09:28:40 -0600 (Wed, 14 Nov 2007) $
Author:
Lane Schwartz
See Also:
"Better k-best Parsing" by Liang Huang & David Chiang (IWPT, 2005)

Field Summary
static String ELIDE_STAR
          A constant holding a special placeholder symbol used when eliding a target language string.
 
Fields inherited from class edu.umn.cs.nlp.mt.huangchiang2005.Hyperarc
head, tail
 
Constructor Summary
RuleApplication(ChartCellEntry terminalEntry)
           
RuleApplication(TranslationRule rule, LanguageModel languageModel, ChartCellEntry head, List<ChartCellEntry> tail)
          Construct a RuleApplication.
 
Method Summary
 int compareTo(RuleApplication r)
           
protected static String elide(String targetLanguagePhrase)
          Implements the q function from Chiang (2007)
 Translation getDerivation(List<Translation> children)
           
 String getElidedTargetLanguagePhrase()
           
 LoglinearTranslationFeatures getFeatures()
           
protected static double getLanguageModelScore(LanguageModel languageModel, String[] words)
          Implements the p function from Chiang (2007)
static int getNGramOrder()
           
 double getRawScore()
          Get the score for this item, without the pruning heuristic.
 LoglinearTranslationFeatures getRuleFeatures()
           
 double getScore()
          Get the score for this item, with the pruning heuristic added in.
 double getWeight()
           
 boolean isTerminal()
           
static void main(String[] args)
           
static void setNGramOrder(int order)
           
 String toString()
           
 String toString(List<Derivation> derivations)
           
 
Methods inherited from class edu.umn.cs.nlp.mt.huangchiang2005.Hyperarc
arity, isSourceVertex, naiveMult, tail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ELIDE_STAR

public static final String ELIDE_STAR
A constant holding a special placeholder symbol used when eliding a target language string.

See Also:
5.3.2 of "Hierarchical Phrase-Based Translation" by David Chiang (Computational Linguistics, 2007), Constant Field Values
Constructor Detail

RuleApplication

public RuleApplication(TranslationRule rule,
                       LanguageModel languageModel,
                       ChartCellEntry head,
                       List<ChartCellEntry> tail)
Construct a RuleApplication. This objects represents the application of the specified rule, such that the new parse chart entry head spans over all of the child cells (specified by tail).

Parameters:
rule -
languageModel -
head -
tail -

RuleApplication

public RuleApplication(ChartCellEntry terminalEntry)
Method Detail

setNGramOrder

public static void setNGramOrder(int order)

getNGramOrder

public static int getNGramOrder()

isTerminal

public boolean isTerminal()

compareTo

public int compareTo(RuleApplication r)
Specified by:
compareTo in interface Comparable<RuleApplication>

getDerivation

public Translation getDerivation(List<Translation> children)
Specified by:
getDerivation in class Hyperarc<ChartCellEntry,Translation>

getRuleFeatures

public LoglinearTranslationFeatures getRuleFeatures()

getFeatures

public LoglinearTranslationFeatures getFeatures()

getWeight

public double getWeight()
Specified by:
getWeight in class Hyperarc<ChartCellEntry,Translation>

getScore

public double getScore()
Get the score for this item, with the pruning heuristic added in.

Specified by:
getScore in interface Scorable
Returns:
the score for this item, with the pruning heuristic added in

getRawScore

public double getRawScore()
Get the score for this item, without the pruning heuristic.

Returns:
the score for this item, without the pruning heuristic

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(List<Derivation> derivations)

getElidedTargetLanguagePhrase

public String getElidedTargetLanguagePhrase()

elide

protected static String elide(String targetLanguagePhrase)
Implements the q function from Chiang (2007)


getLanguageModelScore

protected static double getLanguageModelScore(LanguageModel languageModel,
                                              String[] words)
Implements the p function from Chiang (2007)

Parameters:
languageModel - The language model to use in scoring
words - The possibly elided phrase to score

main

public static void main(String[] args)
                 throws FileNotFoundException
Throws:
FileNotFoundException