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 should 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 elements as the input set,
except the case (all lowercase, or uppercase first letter) matches that of
the input string.
|
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 capitalization should be fixedpublic abstract java.util.Set<java.lang.String> getCorrections(java.lang.String wrong)
Any input that is *not* a valid word (i.e. only composed of letters and/or apostrophes) should throw an IllegalArgumentException.
wrong
- the misspelled wordjava.lang.IllegalArgumentException
- if the input is not a valid word
(i.e. only composed of letters and/or apostrophes)