org.finetracker
Class Hypothesis

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

public class Hypothesis
extends java.lang.Object

This class contains an hypothesis as part of the Viterbi algorithm. It has a certain path in the lexicon, a position in the input stream, and a score, which is based on that path and position.

Author:
Frank Kusters, Albert Gerritsen

Constructor Summary
Hypothesis(Hypothesis h)
          Constructs a new Hypothesis object which is a deep clone of h.
Hypothesis(Node node, java.util.List<FeatureVector> list)
          Constructs a Hypothesis object with references to the specified node and list.
 
Method Summary
 void addFinalPenalty()
          Adds any penalties that need to be added after the algorithm has finished, like the word not finished penalty.
 java.util.List<Hypothesis> advanceInput()
          Advances a copy of this Hypothesis in the input and returns a list containing this copy.
 java.util.List<Hypothesis> advanceInputAndLexicon()
          Advances a copy of this Hypothesis in the input, then in the lexicon.
 java.util.List<Hypothesis> advanceInputAndSilence()
          Advances this hypothesis in the input and matches silence to the input.
 java.util.List<Hypothesis> advanceLexicon(double maxScore)
          Advances this Hypothesis in the lexicon.
 Hypothesis doFinalStep()
          At the end of the algorithm, words that are fully recognized aren't converted to words in the wordHistory.
 boolean equals(java.lang.Object obj)
          Checks if this hypothesis is equal to another.
 java.util.List<java.lang.Character> getCharHistory()
           
 double getScore()
           
 int getUniquenessNumber()
          This uniqueness number is based on the original hashCode()-method.
 java.util.List<java.lang.String> getWordHistory()
           
 int hashCode()
          Generates the hash code for this hypothesis.
 java.lang.String prettyPrint()
          Returns a pretty string representation of this hypothesis.
 java.lang.String toString()
          Returns a string representation of this hypothesis.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hypothesis

public Hypothesis(Node node,
                  java.util.List<FeatureVector> list)
Constructs a Hypothesis object with references to the specified node and list. This constructor is used only once at the start of the algorithm.

Parameters:
node - reference to a Node in the lexicon
list - reference to the inputvectors

Hypothesis

public Hypothesis(Hypothesis h)
Constructs a new Hypothesis object which is a deep clone of h. It also gets a new, unique id.

Parameters:
h - the hypothesis to deep clone
Method Detail

advanceInput

public java.util.List<Hypothesis> advanceInput()
Advances a copy of this Hypothesis in the input and returns a list containing this copy. The score is raised with the corresponding penalty. The object it is called from does not change.

Returns:
the list of advanced hypotheses

advanceInputAndLexicon

public java.util.List<Hypothesis> advanceInputAndLexicon()
Advances a copy of this Hypothesis in the input, then in the lexicon. Returns a list with all elements after stepping in the lexicon. The scores of all elements are not raised with any penalties. The object it is called from does not change.

Returns:
the list of advanced hypotheses

advanceLexicon

public java.util.List<Hypothesis> advanceLexicon(double maxScore)
Advances this Hypothesis in the lexicon. Returns a list with all elements after stepping in the lexicon. The scores of all elements are raised with the corresponding penalties. This function changes the object it is called from, but returns a list of new objects.

Parameters:
maxScore - no hypotheses with a higher score than this should be kept. This is a speed optimization, to prevent them from having to be compared in Hypotheses.HypothesesCollection.
Returns:
the list of advanced hypotheses

advanceInputAndSilence

public java.util.List<Hypothesis> advanceInputAndSilence()
Advances this hypothesis in the input and matches silence to the input. The advance is only done when the hypothesis is at the end of a word. If the hypothesis is not at the end of a word, then no step is taken.

Returns:
a list with the advanced hypothesis if it was at the end of a word, or an empty list if it wasn't at the end of a word

doFinalStep

public Hypothesis doFinalStep()
At the end of the algorithm, words that are fully recognized aren't converted to words in the wordHistory. This method does just that. When the lexiconPosition has a lexical word defined, the word is added to the word history and the character history is cleared. In addition, a new hypothesis is created if this word is also part of a larger word.

Returns:
a new Hypothesis where the character list is still the same (in case the current hypothesis is both complete and part of a larger word), null otherwise

addFinalPenalty

public void addFinalPenalty()
Adds any penalties that need to be added after the algorithm has finished, like the word not finished penalty.


toString

public java.lang.String toString()
Returns a string representation of this hypothesis.

Overrides:
toString in class java.lang.Object
Returns:
the representation

getUniquenessNumber

public int getUniquenessNumber()
This uniqueness number is based on the original hashCode()-method. Only it will ignore silences in the word history (useful for avoiding printing duplicate hypotheses).

Returns:
A number unique to this hypothesis module silences

prettyPrint

public java.lang.String prettyPrint()
Returns a pretty string representation of this hypothesis.

Returns:
the representation

hashCode

public int hashCode()
Generates the hash code for this hypothesis. Note: See comment at self.uniquenessNumber()

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object obj)
Checks if this hypothesis is equal to another.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the hypothesis to check
Returns:
true if this hypothesis is equal to obj, false otherwise.
See Also:
Object.equals(java.lang.Object)

getCharHistory

public java.util.List<java.lang.Character> getCharHistory()
Returns:
the charHistory

getWordHistory

public java.util.List<java.lang.String> getWordHistory()
Returns:
the wordHistory

getScore

public double getScore()
Returns:
the score