Class FileCorrector

  extended by Corrector
      extended by FileCorrector

public class FileCorrector
extends Corrector

A Corrector whose spelling suggestions are given in a text file.

One way to get corrections for a misspelled word is to consult an external resource. This kind of Corrector uses a file that contains pairs of misspelled and corrected words to generate suggestions.

Constructor Summary
FileCorrector(java.lang.String file)
          Constructs an instance from the text file supplied.
Method Summary
 java.util.Set<java.lang.String> getCorrections(java.lang.String wrong)
          Returns a set of proposed corrections for an incorrect word.
Methods inherited from class Corrector
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public FileCorrector(java.lang.String file)
Constructs an instance from the text file supplied. The file should be read once and then closed. Each line of the file should have a single-comma-separated-value format: misspelled_word,corrected_word

For example:
inspite,in spite

This constructor throws an IOException if the file doesn't adhere to above format.

For methods useful in parsing the lines of the File, see the String class documentation in java.lang.String

file - The name of the corrections file.
Method Detail


public java.util.Set<java.lang.String> getCorrections(java.lang.String wrong)
Description copied from class: Corrector
Returns a set of proposed corrections for an incorrect word. The corrections should match the case of the input; the matchCase method may be helpful here.

Specified by:
getCorrections in class Corrector
wrong - the misspelled word. Assume any leading or trailing whitespace has already been removed.
a (potentially empty) set of proposed corrections