pt.tumba.spell
Class Benchmark

java.lang.Object
  extended by pt.tumba.spell.Benchmark

public final class Benchmark
extends java.lang.Object

This is a benchmarking class, usefull for measuring how well this package is doing.

Author:
Bruno Martins

Field Summary
private  int count
          Numer of tests in the benchmark.
private  java.lang.String dictionaryName
          The File path leading up to the dictionary used for the benchmarks.
private  int missed
          Number of missed spelling corrections.
private  java.util.List missedTerms
          A List of all spelling mistakes that were missed.
private  java.io.PrintWriter outStream
          To where the benchmark statistics will be outputed.
private  int topFive
          Numer of spelling corrections made where the correct word was in the top 5 suggestions.
private  int topHundred
          Numer of spelling corrections made where the correct word was in the top 100 suggestions.
private  int topOne
          Numer of spelling corrections made where the correct word was the top suggestion.
private  int topTen
          Numer of spelling corrections made where the correct word was in the top 10 suggestions.
 
Constructor Summary
Benchmark(java.lang.String dictionaryName)
          Constructor for Benchmark.
 
Method Summary
 java.lang.String add(java.lang.String pBadTerm, java.lang.String pCorrectTerm, java.lang.String[] pCandidates)
          This method adds a "term : correct" term pair with its corresponding statistic to the benchmark.
private  int computeWhereSuggested(java.lang.String pCorrectTerm, java.lang.String[] pCandidates)
          This method returns the position in the candidates list where the correct term was found.
static void main(java.lang.String argv)
          This is a test main, whose purpose is to test the functionality of each method developed for this class.
 java.lang.String reportStats()
          This method reports the statistics for this benchmark.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outStream

private java.io.PrintWriter outStream
To where the benchmark statistics will be outputed.


topOne

private int topOne
Numer of spelling corrections made where the correct word was the top suggestion.


topFive

private int topFive
Numer of spelling corrections made where the correct word was in the top 5 suggestions.


topTen

private int topTen
Numer of spelling corrections made where the correct word was in the top 10 suggestions.


topHundred

private int topHundred
Numer of spelling corrections made where the correct word was in the top 100 suggestions.


count

private int count
Numer of tests in the benchmark.


missed

private int missed
Number of missed spelling corrections.


missedTerms

private java.util.List missedTerms
A List of all spelling mistakes that were missed.


dictionaryName

private java.lang.String dictionaryName
The File path leading up to the dictionary used for the benchmarks.

Constructor Detail

Benchmark

public Benchmark(java.lang.String dictionaryName)
          throws java.lang.Exception
Constructor for Benchmark.

Parameters:
dictionaryName - The File path leading up to the dictionary used for the benchmarks.
Throws:
java.lang.Exception
Method Detail

add

public java.lang.String add(java.lang.String pBadTerm,
                            java.lang.String pCorrectTerm,
                            java.lang.String[] pCandidates)
This method adds a "term : correct" term pair with its corresponding statistic to the benchmark.

Parameters:
pBadTerm - The correctly spelled term.
pCorrectTerm - The spelling mistake.
pCandidates - The candidate corrections.
Returns:
A String with the statistic concerning this benchmark.

reportStats

public java.lang.String reportStats()
                             throws java.lang.Exception
This method reports the statistics for this benchmark.

Returns:
The statistics for this benchmark.
Throws:
java.lang.Exception

computeWhereSuggested

private int computeWhereSuggested(java.lang.String pCorrectTerm,
                                  java.lang.String[] pCandidates)
This method returns the position in the candidates list where the correct term was found. It compares the correct term with the candidates in a case insensitive manner.

If the correct answer is not found, this method returns -1. What is returned is one based, not zero based. I.e., if the correct term was found in the 0th element, this routine will return 1.

Parameters:
pCorrectTerm - The correct spelling correction.
pCandidates - A list of Possible corrections.
Returns:
The position in the candidates list where the correct term was found.

main

public static void main(java.lang.String argv)
This is a test main, whose purpose is to test the functionality of each method developed for this class.

This main strives to test the boundary conditions as well as some sample common ways each method is intended to be used.

Parameters:
argv - The command line input, tokenized.