edu.cmu.sphinx.util
Class NISTAlign

java.lang.Object
  extended byedu.cmu.sphinx.util.NISTAlign

public class NISTAlign
extends java.lang.Object

Implements a portion of the NIST align/scoring algorithm to compare a reference string to a hypothesis string. It only keeps track of substitutions, insertions, and deletions.


Constructor Summary
NISTAlign(boolean showResults, boolean showAlignedResults)
          Creates a new NISTAlign object.
 
Method Summary
 boolean align(java.lang.String reference, java.lang.String hypothesis)
          Performs the NIST alignment on the reference and hypothesis strings.
 java.lang.String getAlignedHypothesis()
          Returns the aligned hypothesis string.
 java.lang.String getAlignedReference()
          Returns the aligned reference string.
 java.lang.String getHypothesis()
          Returns the hypothesis string.
 java.lang.String getReference()
          Returns the reference string.
 int getTotalDeletions()
          Gets the total number of deletions
 int getTotalInsertions()
          Gets the total number of insertion errors
 float getTotalSentenceAccuracy()
          Returns the total sentence accuracy.
 int getTotalSentences()
          Gets the total number of sentences
 int getTotalSentencesWithErrors()
          Gets the total number of sentences with errors
 int getTotalSubstitutions()
          Gets the total number of substitution errors
 float getTotalWordAccuracy()
          Returns the total word accuracy.
 float getTotalWordErrorRate()
          Returns the total word accuracy.
 int getTotalWordErrors()
          Gets the total number of word errors for all calls to align.
 int getTotalWords()
          Gets the total number of words
static void main(java.lang.String[] args)
          Take two filenames -- the first contains a list of reference sentences, the second contains a list of hypothesis sentences.
 void printNISTSentenceSummary()
          Prints the results for this sentence to System.out.
 void printNISTTotalSummary()
          Prints the summary for all calls to align to System.out.
 void printSentenceSummary()
          Prints the results for this sentence to System.out.
 void printTotalSummary()
          Prints the total summary for all calls.
 void resetTotals()
          Reset the total insertions, deletions, and substitutions counts for this class.
 void setShowAlignedResults(boolean showAlignedResults)
          Sets whether aligned results are displayed
 void setShowResults(boolean showResults)
          Sets whether results are displayed
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NISTAlign

public NISTAlign(boolean showResults,
                 boolean showAlignedResults)
Creates a new NISTAlign object.

Method Detail

setShowResults

public void setShowResults(boolean showResults)
Sets whether results are displayed

Parameters:
showResults - true if the results should be displayed

setShowAlignedResults

public void setShowAlignedResults(boolean showAlignedResults)
Sets whether aligned results are displayed

Parameters:
showAlignedResults - true if the aligned results should be displayed

resetTotals

public void resetTotals()
Reset the total insertions, deletions, and substitutions counts for this class.


align

public boolean align(java.lang.String reference,
                     java.lang.String hypothesis)
Performs the NIST alignment on the reference and hypothesis strings. This has the side effect of updating nearly all the fields of this class.

Parameters:
reference - the reference string
hypothesis - the hypothesis string
Returns:
true if the reference and hypothesis match

getReference

public java.lang.String getReference()
Returns the reference string. This string will be filtered (all spurious whitespace removed and annotation removed) and set to all lower case.

Returns:
the reference string

getHypothesis

public java.lang.String getHypothesis()
Returns the hypothesis string. This string will be filtered (all spurious whitespace removed and annotation removed) and set to all lower case.

Returns:
the hypothesis string

getAlignedReference

public java.lang.String getAlignedReference()
Returns the aligned reference string.

Returns:
the aligned reference string

getAlignedHypothesis

public java.lang.String getAlignedHypothesis()
Returns the aligned hypothesis string.

Returns:
the aligned hypothesis string

getTotalWordErrors

public int getTotalWordErrors()
Gets the total number of word errors for all calls to align.

Returns:
the total number of word errors for all calls to align

getTotalWordAccuracy

public float getTotalWordAccuracy()
Returns the total word accuracy.

Returns:
the accuracy between 0.0 and 1.0

getTotalWordErrorRate

public float getTotalWordErrorRate()
Returns the total word accuracy.

Returns:
the accuracy between 0.0 and 1.0

getTotalSentenceAccuracy

public float getTotalSentenceAccuracy()
Returns the total sentence accuracy.

Returns:
the accuracy between 0.0 and 1.0

getTotalWords

public int getTotalWords()
Gets the total number of words

Returns:
the total number of words

getTotalSubstitutions

public int getTotalSubstitutions()
Gets the total number of substitution errors

Returns:
the total number of substitutions

getTotalInsertions

public int getTotalInsertions()
Gets the total number of insertion errors

Returns:
the total number of insertion errors

getTotalDeletions

public int getTotalDeletions()
Gets the total number of deletions

Returns:
the total number of deletions

getTotalSentences

public int getTotalSentences()
Gets the total number of sentences

Returns:
the total number of sentences

getTotalSentencesWithErrors

public int getTotalSentencesWithErrors()
Gets the total number of sentences with errors

Returns:
the total number of sentences with errors

printSentenceSummary

public void printSentenceSummary()
Prints the results for this sentence to System.out. If you want the output to match the NIST output, see printNISTSentenceSummary.

See Also:
printNISTSentenceSummary()

printTotalSummary

public void printTotalSummary()
Prints the total summary for all calls. If you want the output to match the NIST output, see printNISTTotalSummary.

See Also:
printNISTTotalSummary()

printNISTSentenceSummary

public void printNISTSentenceSummary()
Prints the results for this sentence to System.out. This matches the output from the NIST aligner.


printNISTTotalSummary

public void printNISTTotalSummary()
Prints the summary for all calls to align to System.out. This matches the output from the NIST aligner.


main

public static void main(java.lang.String[] args)
Take two filenames -- the first contains a list of reference sentences, the second contains a list of hypothesis sentences. Aligns each pair of sentences and outputs the individual and total results.