com.swabunga.spell.engine
Class DoubleMeta
public
class
DoubleMeta
extends Object
implements Transformator
A phonetic encoding algorithm that takes an English word and computes a phonetic version of it. This
allows for phonetic matches in a spell checker. This class is a port of the C++ DoubleMetaphone() class,
which was intended to return two possible phonetic translations for certain words, although the Java version
only seems to be concerned with one, making the "double" part erroneous.
source code for the original C++ can be found
here:
http://aspell.sourceforge.net/metaphone/
DoubleMetaphone does some processing, such as uppercasing, on the input string first to normalize it. Then, to
create the key, the function traverses the input string in a while loop, sending successive characters into a giant
switch statement. Before determining the appropriate pronunciation, the algorithm considers the context
surrounding each character within the input string.
Things that were changed:
The alternate flag could be set to true but was never checked so why bother with it. REMOVED
Why was this class serializable?
The primary, in, length and last variables could be initialized and local to the
process method and references passed around the appropriate methods. As such there are
no class variables and this class becomes firstly threadsafe and secondly could be static final.
The function call SlavoGermaic was called repeatedly in the process function, it is now only called once.
public char[] getReplaceList()
public final String transform(String word)
Take the given word, and return the best phonetic hash for it.
Vowels are minimized as much as possible, and consenants
that have similiar sounds are converted to the same consenant
for example, 'v' and 'f' are both converted to 'f'
Parameters: word the texte to transform
Returns: the result of the phonetic transformation