public class Hunspell extends Object
The objects of this class are thread-safe.
Constructor and Description |
---|
Hunspell(Dictionary dictionary) |
Hunspell(Dictionary dictionary,
TimeoutPolicy policy,
Runnable checkCanceled) |
Modifier and Type | Method and Description |
---|---|
List<String> |
getRoots(String word)
Find all roots that could result in the given word after case conversion and adding affixes.
|
boolean |
spell(String word) |
List<String> |
suggest(String word) |
List<String> |
suggest(String word,
long timeLimitMs) |
public Hunspell(Dictionary dictionary)
public Hunspell(Dictionary dictionary, TimeoutPolicy policy, Runnable checkCanceled)
policy
- a strategy determining what to do when API calls take too much timecheckCanceled
- an object that's periodically called, allowing to interrupt spell-checking
or suggestion generation by throwing an exceptionpublic boolean spell(String word)
public List<String> getRoots(String word)
hunspell -s
(stemming) functionality.
Some affix rules are relaxed in this stemming process: e.g. explicitly forbidden words are still returned. Some of the returned roots may be synthetic and not directly occur in the *.dic file (but differ from some existing entries in case). No roots are returned for compound words.
The returned roots may be used to retrieve morphological data via Dictionary.lookupEntries(java.lang.String)
.
public List<String> suggest(String word) throws SuggestionTimeoutException
SuggestionTimeoutException
- if the computation takes too long and TimeoutPolicy.THROW_EXCEPTION
was specified in the constructorpublic List<String> suggest(String word, long timeLimitMs) throws SuggestionTimeoutException
word
- the misspelled word to calculate suggestions fortimeLimitMs
- the duration limit in milliseconds, after which the associated TimeoutPolicy
's effects (exception or partial result) may kick inSuggestionTimeoutException
- if the computation takes too long and TimeoutPolicy.THROW_EXCEPTION
was specified in the constructorCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.