Interface SpellChecker
- All Known Implementing Classes:
SymSpell
suggestions for individual
terms and corrects whole sentences.
Implementations are expected to be thread-safe for concurrent lookup calls
once their dictionary has been fully populated and safely published to the reading
threads (e.g. stored in a final field, or otherwise guarded so a happens-before
edge exists between population and the first read). Population itself is not required to
be thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionConvenience overload that usesVerbosity.TOPand the implementation's configured maximum dictionary edit distance.Looks up suggestions for a singletermwithinmaxEditDistance.lookupCompound(String input, int maxEditDistance) Corrects a whole input string (a phrase or sentence), supporting word splits and merges, and combining candidates using a bigram language model.int
-
Method Details
-
lookup
Looks up suggestions for a singletermwithinmaxEditDistance.A blank (empty or whitespace-only)
termis a valid argument: it is looked up verbatim and, as it matches no dictionary entry, normally yields an empty list rather than an error.- Parameters:
term- the (possibly misspelled) term to correct; must not benullverbosity- controls how many suggestions are returned; must not benullmaxEditDistance- the maximum edit distance to consider; must not be negative and must not exceedmaxEditDistance()- Returns:
- the matching suggestions in natural order (best first); never
null - Throws:
NullPointerException- iftermorverbosityisnullIllegalArgumentException- ifmaxEditDistanceis negative or exceedsmaxEditDistance()
-
maxEditDistance
int maxEditDistance()- Returns:
- the largest edit distance this checker can answer queries for (the configured
maximum dictionary edit distance); a
maxEditDistanceargument tolookup(String, Verbosity, int)must not exceed this value.
-
lookup
Convenience overload that usesVerbosity.TOPand the implementation's configured maximum dictionary edit distance.As with
lookup(String, Verbosity, int), a blanktermis looked up verbatim and normally yields an empty list.- Parameters:
term- the (possibly misspelled) term to correct; must not benull- Returns:
- the matching suggestions in natural order (best first); never
null - Throws:
NullPointerException- iftermisnull
-
lookupCompound
Corrects a whole input string (a phrase or sentence), supporting word splits and merges, and combining candidates using a bigram language model.A blank (empty or whitespace-only)
inputis a valid argument: it contains no tokens to correct, so the returned singleton holds a suggestion whose term is the empty string at edit distance0.- Parameters:
input- the input phrase to correct; must not benullmaxEditDistance- the maximum edit distance per token; must not be negative- Returns:
- a singleton list holding the best correction of the whole input; never
null - Throws:
NullPointerException- ifinputisnullIllegalArgumentException- ifmaxEditDistanceis negative
-