edu.cmu.sphinx.result
Class Sausage

java.lang.Object
  extended by edu.cmu.sphinx.result.Sausage
All Implemented Interfaces:
ConfidenceResult

public class Sausage
extends java.lang.Object
implements ConfidenceResult

A Sausage is a sequence of confusion sets, one for each position in an utterance.

Author:
pgorniak

Constructor Summary
Sausage(int size)
          Construct a new sausage.
 
Method Summary
 void addWordHypothesis(int position, java.lang.String word, double confidence, LogMath logMath)
           
 void addWordHypothesis(int position, WordResult word)
          Add a word hypothesis to a given word slot in the sausage.
 java.util.Iterator confusionSetIterator()
          Get an iterator for the sausage.
 java.util.Iterator confusionSetIterator(int i)
          Get an iterator for the sausage.
 int countWordHypotheses()
           
 void dumpAISee(java.lang.String fileName, java.lang.String title)
          Write this sausage to an aisee format text file.
 void fillInBlanks(LogMath logMath)
          Adds skip elements for each word slot in which the word posteriors do not add up to linear 1.
 Path getBestHypothesis()
          Returns the best hypothesis of the result.
 Path getBestHypothesisNoFiller()
          Get the best hypothesis path discarding any filler words.
 java.lang.String getBestHypothesisString()
          Get a string representing the best path through the sausage.
 java.util.Set getBestWordHypothesis(int pos)
          Get the word hypothesis with the highest posterior for a word slot
 double getBestWordHypothesisPosterior(int pos)
          Get the the highest posterior for a word slot
 ConfusionSet getConfusionSet(int pos)
          Get the confusion set stored in a given word slot.
 void removeFillers()
          Remove all filler words from the sausage.
 int size()
          size of this sausage in word slots.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sausage

public Sausage(int size)
Construct a new sausage.

Parameters:
size - The number of word slots in the sausage
Method Detail

confusionSetIterator

public java.util.Iterator confusionSetIterator()
Get an iterator for the sausage. The iterator will return SortedMaps, which are confusion sets mapping Double posteriors to Sets of word Strings.

Specified by:
confusionSetIterator in interface ConfidenceResult
Returns:
an iterator that steps through confusion sets

confusionSetIterator

public java.util.Iterator confusionSetIterator(int i)
Get an iterator for the sausage. The iterator will return SortedMaps, which are confusion sets mapping Double posteriors to Sets of word Strings.

Parameters:
i - the index to start the iterator off at
Returns:
an iterator that steps through confusion sets

fillInBlanks

public void fillInBlanks(LogMath logMath)
Adds skip elements for each word slot in which the word posteriors do not add up to linear 1.

Parameters:
logMath - the log math object to use for probability computations

addWordHypothesis

public void addWordHypothesis(int position,
                              WordResult word)
Add a word hypothesis to a given word slot in the sausage.

Parameters:
position - the position to add a hypothesis to
word - the word to add

addWordHypothesis

public void addWordHypothesis(int position,
                              java.lang.String word,
                              double confidence,
                              LogMath logMath)

getBestHypothesis

public Path getBestHypothesis()
Description copied from interface: ConfidenceResult
Returns the best hypothesis of the result.

Specified by:
getBestHypothesis in interface ConfidenceResult
Returns:
the best hypothesis of the result
See Also:
ConfidenceResult.getBestHypothesis()

getBestHypothesisNoFiller

public Path getBestHypothesisNoFiller()
Get the best hypothesis path discarding any filler words.

Returns:
the best path without fillers

removeFillers

public void removeFillers()
Remove all filler words from the sausage. Also removes confusion sets that might've been emptied in the process of removing fillers.


getBestHypothesisString

public java.lang.String getBestHypothesisString()
Get a string representing the best path through the sausage.

Returns:
best string

getBestWordHypothesis

public java.util.Set getBestWordHypothesis(int pos)
Get the word hypothesis with the highest posterior for a word slot

Parameters:
pos - the word slot to look at
Returns:
the word with the highest posterior in the slot

getBestWordHypothesisPosterior

public double getBestWordHypothesisPosterior(int pos)
Get the the highest posterior for a word slot

Parameters:
pos - the word slot to look at
Returns:
the highest posterior in the slot

getConfusionSet

public ConfusionSet getConfusionSet(int pos)
Get the confusion set stored in a given word slot.

Specified by:
getConfusionSet in interface ConfidenceResult
Parameters:
pos - the word slot to look at.
Returns:
a map from Double posteriors to Sets of String words, sorted from lowest to highest.

countWordHypotheses

public int countWordHypotheses()

size

public int size()
size of this sausage in word slots.

Specified by:
size in interface ConfidenceResult
Returns:
The number of word slots in this sausage

dumpAISee

public void dumpAISee(java.lang.String fileName,
                      java.lang.String title)
Write this sausage to an aisee format text file.

Parameters:
fileName - The file to write to.
title - the title to give the graph.