org.finetracker
Class Hypotheses

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

public class Hypotheses
extends java.lang.Object

The Hypotheses class contains all Hypothesis-objects that have survived the previous iteration of the Viterbi-algorithm. It also allows executing this algorithm.

Author:
Frank Kusters

Constructor Summary
Hypotheses(Node lexicon, java.util.List<FeatureVector> input)
          Creates the Hypotheses object.
 
Method Summary
 void calculateHypotheses()
          This method executes the viterbi algorithm.
 void finishHypotheses()
          Converts any complete words to its complete counterparts, then adds any penalties that need to be added after the algorithm has finished.
 java.util.List<Hypothesis> getTopHypotheses(int top, boolean onlyUnique)
          Gets the n best scoring hypotheses.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Hypotheses

public Hypotheses(Node lexicon,
                  java.util.List<FeatureVector> input)
Creates the Hypotheses object. It is populated with one Hypothesis, from which the algorithm will start calculating.

Parameters:
lexicon - the lexicon of the application.
input - the input of the application.
Method Detail

calculateHypotheses

public void calculateHypotheses()
This method executes the viterbi algorithm. It takes one step in the input, and loops around through the entire lexicon until the scores are too high. To control the hypotheses that loop through the lexicon, a queue is created. We add all hypotheses that aren't up to speed at the input to the queue. This queue is then processed on a FIFO basis. Each iteration removes an element, and, if the scores aren't getting too high, adds elements. Because the scores for stepping in the lexicon grow faster than scores for stepping in the input or both the lexicon and input, eventually no more elements will be added to the queue. It will then shrink until it is empty and the loop stops. The hypotheses in allHypotheses are the best n hypothesis for the input at this time, where n is equal to Main.MAX_HYPOTHESES.


finishHypotheses

public void finishHypotheses()
Converts any complete words to its complete counterparts, then adds any penalties that need to be added after the algorithm has finished.


getTopHypotheses

public java.util.List<Hypothesis> getTopHypotheses(int top,
                                                   boolean onlyUnique)
Gets the n best scoring hypotheses. Those best scoring scoring hypotheses are those with the lowest scores (least difference with the input).

Parameters:
top - the number of hypotheses wanted
Returns:
the lowest scoring hypotheses