org.finetracker
Class LMExtension

java.lang.Object
  extended by org.finetracker.LMExtension

public class LMExtension
extends java.lang.Object

LanuageModel-penalties are stored in the Lexicon-tree, each Node contains some fields which are maintained by this class. Interpretation and decoration are the responsibility of this class, so only change/read the "Node.lmext_*"-variables via methods of this class!

Author:
Albert Gerritsen

Constructor Summary
LMExtension()
          Constructs a LMExtension from the file listed in the configuration.
LMExtension(LanguageModel lm)
          Constructs a LMExtension from a supplied LanguageModel
 
Method Summary
 void apply(Lexicon lexicon, boolean pushUG, boolean moveBGWhenFinal)
          Applies the LM to the Lexicon by distributing the penalties over the Lexicon-tree.
 double getBGFinalPenalty(Node n, java.lang.String prevWord)
          Get the unigram penalty that we suffer by leaving/finalizing n
 double getBGStepPenalty(Node n, java.lang.String prevWord)
          Get the bigram penalty that we suffer by entering n
 double getUGFinalPenalty(Node n)
          Get the unigram penalty that we suffer by leaving/finalizing n
 double getUGStepPenalty(Node n)
          Get the unigram penalty that we suffer by entering n
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LMExtension

public LMExtension()
            throws java.io.IOException
Constructs a LMExtension from the file listed in the configuration. When the file cannot be found an exception is raised that is to be handled by the Main-function of finetracker.

Throws:
java.io.IOException

LMExtension

public LMExtension(LanguageModel lm)
Constructs a LMExtension from a supplied LanguageModel

Parameters:
lm - The LanguageModel that is used by this LMExtension
Method Detail

apply

public void apply(Lexicon lexicon,
                  boolean pushUG,
                  boolean moveBGWhenFinal)
Applies the LM to the Lexicon by distributing the penalties over the Lexicon-tree.

Parameters:
lexicon - The lexicon that needs decorating
pushUG - Apply Pushing to UG-penalties
moveBGWhenFinal - Move BG-penalties up final branches (branches that must lead to a single word)

getUGStepPenalty

public double getUGStepPenalty(Node n)
Get the unigram penalty that we suffer by entering n

Parameters:
n - The node that is entered
Returns:
The penalty associated with this step in the lexicon

getUGFinalPenalty

public double getUGFinalPenalty(Node n)
Get the unigram penalty that we suffer by leaving/finalizing n

Parameters:
n - The node that is finished
Returns:
The penalty associated with this step in the lexicon

getBGStepPenalty

public double getBGStepPenalty(Node n,
                               java.lang.String prevWord)
Get the bigram penalty that we suffer by entering n

Parameters:
n - The node that is entered
prevWord - The previous word
Returns:
The penalty associated with this step in the lexicon

getBGFinalPenalty

public double getBGFinalPenalty(Node n,
                                java.lang.String prevWord)
Get the unigram penalty that we suffer by leaving/finalizing n

Parameters:
n - The node that is finished
prevWord - The previous word
Returns:
The penalty associated with this step in the lexicon