edu.cmu.sphinx.result
Class Result

java.lang.Object
  extended byedu.cmu.sphinx.result.Result

public class Result
extends java.lang.Object

Provides recognition results. Results can be partial or final. A result should not be modified before it is a final result. Note that a result may not contain all possible information. The following methods are not yet defined but should be:

 public Result getDAG(int compressionLevel);
 


Constructor Summary
Result(ActiveList activeList, java.util.List resultList, int frameNumber, boolean isFinal, LogMath logMath)
          Creates a result
Result(AlternateHypothesisManager alternateHypothesisManager, ActiveList activeList, java.util.List resultList, int frameNumber, boolean isFinal, LogMath logMath)
          Creates a result
 
Method Summary
 java.util.List findPartialMatchingTokens(java.lang.String text)
          Searches through the n-best list to find the the branch that matches the beginning of the given string
 Token findToken(java.lang.String text)
          Searches through the n-best list to find the the branch that matches the given string
 ActiveList getActiveTokens()
          Returns a list of active tokens for this result.
 AlternateHypothesisManager getAlternateHypothesisManager()
          Returns the AlternateHypothesisManager Used to construct a Lattice
 Token getBestActiveParitalMatchingToken(java.lang.String text)
          Returns the best scoring token that matches the beginning of the given text.
 Token getBestActiveToken()
          Returns the best scoring token in the active set
 java.lang.String getBestFinalResultNoFiller()
          Returns the string of the best final result, removing any filler words.
 Token getBestFinalToken()
          Returns the best scoring final token in the result.
 java.lang.String getBestResultNoFiller()
          Returns the string of the best result, removing any filler words.
 Token getBestToken()
          Returns the best scoring token in the result.
 Data[] getDataFrames()
          Gets the feature frames associated with this result
 int getEndFrame()
          Gets the ending frame number for the result
 int getFrameNumber()
          Returns the current frame number
 FrameStatistics[] getFrameStatistics()
          Returns detailed frame statistics for this result
 LogMath getLogMath()
          Returns the log math used for this Result.
 java.lang.String getReferenceText()
          Retrieves the reference text.
 java.util.List getResultTokens()
          Returns a list of result tokens for this result.
 int getStartFrame()
          Gets the starting frame number for the result
 java.lang.String getTimedBestResult(boolean wantFiller, boolean wordTokenFirst)
          Returns the string of words (with timestamp) for this token.
 boolean isFinal()
          Determines if the result is a final result.
 void setReferenceText(java.lang.String ref)
          Sets the reference text
 java.lang.String toString()
          Returns a string representation of this object
 boolean validate()
          Determines if the Result is valid.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Result

public Result(AlternateHypothesisManager alternateHypothesisManager,
              ActiveList activeList,
              java.util.List resultList,
              int frameNumber,
              boolean isFinal,
              LogMath logMath)
Creates a result

Parameters:
activeList - the active list associated with this result
resultList - the result list associated with this result
frameNumber - the frame number for this result.
isFinal - if true, the result is a final result

Result

public Result(ActiveList activeList,
              java.util.List resultList,
              int frameNumber,
              boolean isFinal,
              LogMath logMath)
Creates a result

Parameters:
activeList - the active list associated with this result
resultList - the result list associated with this result
frameNumber - the frame number for this result.
isFinal - if true, the result is a final result
Method Detail

isFinal

public boolean isFinal()
Determines if the result is a final result. A final result is guaranteed to no longer be modified by the SearchManager that generated it. Non-final results can be modifed by a SearchManager.recognize calls.

Returns:
true if the result is a final result

getLogMath

public LogMath getLogMath()
Returns the log math used for this Result.

Returns:
the log math used

getActiveTokens

public ActiveList getActiveTokens()
Returns a list of active tokens for this result. The list contains zero or active Token objects that represents the leaf nodes of all active branches in the result (sometimes referred to as the 'lattice'). The lattice is live and may be modified by a SearchManager during a recognition. Once the Result is final, the lattice is fixed and will no longer be modified by the SearchManager. Applications can modify the lattice (to prepare for a re-recognition, for example) only after isFinal returns true

Returns:
a list containing the active tokens for this result
See Also:
Token

getResultTokens

public java.util.List getResultTokens()
Returns a list of result tokens for this result. The list contains zero or more result Token objects that represents the leaf nodes of all final branches in the result (sometimes referred to as the 'lattice'). The lattice is live and may be modified by a SearchManager during a recognition. Once the Result is final, the lattice is fixed and will no longer be modified by the SearchManager. Applications can modify the lattice (to prepare for a re-recognition, for example) only after isFinal returns true

Returns:
a list containing the final result tokens for this result
See Also:
Token

getAlternateHypothesisManager

public AlternateHypothesisManager getAlternateHypothesisManager()
Returns the AlternateHypothesisManager Used to construct a Lattice

Returns:
the AlternateHypothesisManager

getFrameNumber

public int getFrameNumber()
Returns the current frame number

Returns:
the frame number

getBestFinalToken

public Token getBestFinalToken()
Returns the best scoring final token in the result. A final token is a token that has reached a final state in the current frame.

Returns:
the best scoring final token or null

getBestToken

public Token getBestToken()
Returns the best scoring token in the result. First, the best final token is retrieved. A final token is one that has reached the final state in the search space. If no final tokens can be found, then the best, non-final token is returned.

Returns:
the best scoring token or null

getBestActiveToken

public Token getBestActiveToken()
Returns the best scoring token in the active set

Returns:
the best scoring token or null

findToken

public Token findToken(java.lang.String text)
Searches through the n-best list to find the the branch that matches the given string

Parameters:
text - the string to search for
Returns:
the token at the head of the branch or null

findPartialMatchingTokens

public java.util.List findPartialMatchingTokens(java.lang.String text)
Searches through the n-best list to find the the branch that matches the beginning of the given string

Parameters:
text - the string to search for
Returns:
the list token at the head of the branch

getBestActiveParitalMatchingToken

public Token getBestActiveParitalMatchingToken(java.lang.String text)
Returns the best scoring token that matches the beginning of the given text.

Parameters:
text - the text to match

getFrameStatistics

public FrameStatistics[] getFrameStatistics()
Returns detailed frame statistics for this result

Returns:
frame statistics for this result as an array, with one element per frame or null if no frame statistics are available.

getStartFrame

public int getStartFrame()
Gets the starting frame number for the result

Returns:
the starting frame number for the result

getEndFrame

public int getEndFrame()
Gets the ending frame number for the result

Returns:
the ending frame number for the result

getDataFrames

public Data[] getDataFrames()
Gets the feature frames associated with this result

Returns:
the set of feature frames associated with this result, or null if the frames are not available.

getBestResultNoFiller

public java.lang.String getBestResultNoFiller()
Returns the string of the best result, removing any filler words. This method first attempts to return the best final result, that is, the result that has reached the final state of the search space. If there are no best final results, then the best non-final result, that is, the one that did not reach the final state, is returned.

Returns:
the string of the best result, removing any filler words

getBestFinalResultNoFiller

public java.lang.String getBestFinalResultNoFiller()
Returns the string of the best final result, removing any filler words. A final result is a path that has reached the final state. A Result object can also contain paths that did not reach the final state, and those paths are not returned by this method.

Returns:
the string of the best result, removing any filler words, or null if there are no best results

getTimedBestResult

public java.lang.String getTimedBestResult(boolean wantFiller,
                                           boolean wordTokenFirst)
Returns the string of words (with timestamp) for this token.

Parameters:
wantFiller - true if we want filler words included, false otherwise
wordTokenFirst - true if the word tokens come before other types of tokens
Returns:
the string of words

toString

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


validate

public boolean validate()
Determines if the Result is valid. This is used for testing and debugging

Returns:
true if the result is properly formed.

setReferenceText

public void setReferenceText(java.lang.String ref)
Sets the reference text

Parameters:
ref - the reference text

getReferenceText

public java.lang.String getReferenceText()
Retrieves the reference text. The reference text is a transcript of the text that was spoken.

Returns:
the reference text or null if no reference text exists.