ISpellCheckEngine
.
Implementations of this interface provide support for life-cycle management, registering and unregistering
dictionaries, changing the locale of the engine and creating a spell-checker for a specific language.
The following steps are needed to obtain a spell-checker for a specific language:
ISpellCheckEngine
. In this package, no default implementation is provided,
since the management of the dictionary registering and loading is application dependent. Usually, instances
of ISpellCheckEngine
are implemented as singletons.ISpellCheckEngine
must implement the interface ISpellCheckDictionary
.
For this interface, an abstract implementation is provided in the class AbstractSpellDictionary
.
Depending on the language of the words contained in this dictionary, custom algorithms for the phonetic hash
(IPhoneticHashProvider
) and the edit distance (IPhoneticDistanceAlgorithm
) should be implemented
and registered with the dictionary.createSpellChecker(Locale)
, where the locale
denotes the language that the spell-checker should use while executing.createSpellChecker(Locale)
, the spell-checker is
reconfigured with the new dictionaries. More concretely, the old dictionary is unregistered and a new one registered for the
desired locale is associated with the spell-checker. If no such dictionary is available, no spell-checker is returned and
the locale of the engine is reset to its default locale.
ISpellDictionary
. It provides support for life-cycle management as well as the facility to query
words from the list, add words to the list and get correction proposals for incorrectly spelt words.
This package provides a default implementation of a dictionary (AbstractSpellDictionary
) that uses algorithms
convenient for english languages.
Every dictionary needs two kinds of algorithms to be plugged in:
IPhoneticDistanceAlgorithm
. The algorithm
is used to determine the similarity between two words. This package provides a default implementation for languages using the latin alphabet (DefaultPhoneticDistanceAlgorithm
).
The default algorithm uses the Levenshtein text edit distance.IPhoneticHashProvider
. The purpose of
phonetic hashes is to have a representation of words which allows comparing it to other, similar words. This package provides a default
implementation which is convenient for slavic and english languages. It uses the double metaphone algorithm by published
Lawrence Philips.AbstractSpellDictionary
can
be customized to specified languages and alphabets.
ISpellChecker
are usually language-, locale- and medium independent implementations and therefore need an input provider. The
interface ISpellCheckIterator
serves this purpose by abstracting the tokenizing of text media to a simple iteration. The actual spell-check process
is launched by calling ISpellChecker#execute(ISpellCheckIterator)
. This method uses the indicated spell-check iterator to determine the
words that are to be spell-checked. This package provides no default implementation of a spell-check iterator.
ISpellEventListener
and register with the spell-checker before the spell-check process starts.A spell event contains the following information: