public abstract class Corrector
extends java.lang.Object
The matchCase method is code that is shared among all Correctors.
Concrete subclasses of this abstract class must implement the getCorrections method (which will usually call matchCase).
Constructor and Description |
---|
Corrector() |
Modifier and Type | Method and Description |
---|---|
abstract java.util.Set<java.lang.String> |
getCorrections(java.lang.String wrong)
Returns a set of proposed corrections for an incorrectly spelled word.
|
java.util.Set<java.lang.String> |
matchCase(java.lang.String incorrectWord,
java.util.Set<java.lang.String> corrections)
Returns a new set that contains the same words as the argued set but with the case matching
that of the argued misspelled word (either all lowercase or first letter uppercase).
|
public java.util.Set<java.lang.String> matchCase(java.lang.String incorrectWord, java.util.Set<java.lang.String> corrections)
incorrectWord
- The word whose case should be matchedcorrections
- The set whose case should be fixedjava.lang.IllegalArgumentException
- If either argument is nullpublic abstract java.util.Set<java.lang.String> getCorrections(java.lang.String wrong)
For any input that is *not* a valid word, throw an IllegalArgumentException. A valid word is any sequence of letters (as determined by Character.isLetter) or apostrophes characters.
wrong
- The misspelled wordjava.lang.IllegalArgumentException
- If the input is not a valid word (i.e. not composed of only
letters and/or apostrophes)