public class SpellEvaluator extends Object
SpellEvaluator provides an evaluation harness for
spell checkers. As with the other evaluator classes, it is
constructed with the spell checker that will be evaluated. Test
cases are presented to the evaluator using the addCase(String,String) method. The getLastCaseReport()
method returns a string-based representation of the performance of
the most recently provided test case. The method toString() provides a general report of results.
The method normalize(String) may be used to normalize
both input text and system outputs before comparing them. This
may be used to do an evaluation that is case or space or
punctuation insensitive, for example.
The basic output of the spell checker evaluation classifies test cases into one of five categories:
User Input System Suggestion Status Method Correct No Suggestion TN userCorrectSystemNoSuggestion()Correct Wrong Suggestion FP userCorrectSystemWrongSuggestion()Error Correct Suggestion TP userErrorSystemCorrect()Error No Suggestion FN userErrorSystemNoSuggestion()Error Wrong Suggestion FN,FP userErrorSystemWrongSuggestion()
The status indicates whether the case counts as a true positive
(TP), false positive (FP), true negative (TN), or false negative
(FN). Note that if the user's input contains an error and the
system provides the wrong suggestion, the result counts as both a
false negative (failure to correct) and a false positive (erroneous
correction). Because of the case of user
input error and wrong system correction, the confusion matrix count
is not quite one-to-one in size with the input size. A confusion
matrix may be retrieved (populated with the above counts) through
the method confusionMatrix().
The methods for extracting the cases are listed in the final column for each of the five result types.
| Constructor and Description |
|---|
SpellEvaluator(SpellChecker checker)
Construct a spelling evaluator for the specified spell checker.
|
SpellEvaluator(SpellChecker checker,
ObjectToCounterMap<String> tokenCounter)
Construct a spelling evaluator for the specified spell checker
with the specified token counts.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCase(String text,
String correctText)
Adds a training case to the spelling evaluator in the form
of input text and its corrected form.
|
ConfusionMatrix |
confusionMatrix()
Returns the confusion matrix for the current state of this
evaluation.
|
String |
getLastCaseReport()
Returns a string-based representation of the last test case.
|
String |
normalize(String text)
Return the normalized form of a query or system output.
|
String |
toString()
Return a string-based representation of the current status
of this evaluation.
|
String[][] |
userCorrectSystemNoSuggestion()
Returns an array of cases for which the user was correct
and the system made no suggestions.
|
String[][] |
userCorrectSystemWrongSuggestion()
Returns an array of cases for which the user was correct and
the system made an erroneous suggestion.
|
String[][] |
userErrorSystemCorrect()
Returns an array of cases for which the user made an error and
system returned the appropriate correction.
|
String[][] |
userErrorSystemNoSuggestion()
Returns an array of cases for which the user made an
error and the systme made no suggestion.
|
String[][] |
userErrorSystemWrongSuggestion()
Returns an array of cases for which the user made an error and
system returned the appropriate correction.
|
public SpellEvaluator(SpellChecker checker)
checker - Spell checker to evaluate.public SpellEvaluator(SpellChecker checker, ObjectToCounterMap<String> tokenCounter)
null,
no token reports are provided. In order for the token counts
to be used, the spell checker must be an instance of
CompiledSpellChecker.checker - Spell checker to evaluate.tokenCounter - Counter for tokens in the speller.public void addCase(String text, String correctText)
text - Text to spell check.correctText - Correct form of input text.public String toString()
public String[][] userCorrectSystemNoSuggestion()
{text,correct,suggestion}.public String[][] userCorrectSystemWrongSuggestion()
{text,correct,suggestion}.public String[][] userErrorSystemCorrect()
{text,correct,suggestion}.public String[][] userErrorSystemWrongSuggestion()
{text,correct,suggestion}.public String[][] userErrorSystemNoSuggestion()
{text,correct,suggestion}.public String getLastCaseReport()
public ConfusionMatrix confusionMatrix()
"correct" and
"misspelled".
The confusion matrix does not track this evaluator, so once a confusion matrix is constructed and returned, it will not reflect additional cases added to this evaluator.
public String normalize(String text)
The default implementation in this class does nothing, simply returning the input text. Subclasses may override this normalizer.
text - Text to normalize.Copyright © 2016 Alias-i, Inc.. All rights reserved.