public class DaitchMokotoffSoundex extends java.lang.Object implements StringEncoder
The Daitch-Mokotoff Soundex algorithm is a refinement of the Russel and American Soundex algorithms, yielding greater accuracy in matching especially Slavish and Yiddish surnames with similar pronunciation but differences in spelling.
The main differences compared to the other soundex variants are:
This implementation supports branching, depending on the used method:
encode(String)
- branching disabled, only the first code will be returned
soundex(String)
- branching enabled, all codes will be returned, separated by '|'
Note: this implementation has additional branching rules compared to the original description of the algorithm. The
rules can be customized by overriding the default rules contained in the resource file
org/apache/commons/codec/language/dmrules.txt
.
This class is thread-safe.
Soundex
,
Wikipedia - Daitch-Mokotoff Soundex,
Avotaynu - Soundexing and GenealogyConstructor and Description |
---|
DaitchMokotoffSoundex()
Creates a new instance with ASCII-folding enabled.
|
DaitchMokotoffSoundex(boolean folding)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
encode(java.lang.Object obj)
Encodes an Object using the Daitch-Mokotoff soundex algorithm without branching.
|
java.lang.String |
encode(java.lang.String source)
Encodes a String using the Daitch-Mokotoff soundex algorithm without branching.
|
java.lang.String |
soundex(java.lang.String source)
Encodes a String using the Daitch-Mokotoff soundex algorithm with branching.
|
public DaitchMokotoffSoundex()
public DaitchMokotoffSoundex(boolean folding)
With ASCII-folding enabled, certain accented characters will be transformed to equivalent ASCII characters, e.g. -> e.
folding
- if ASCII-folding shall be performed before encodingpublic java.lang.Object encode(java.lang.Object obj) throws EncoderException
This method is provided in order to satisfy the requirements of the Encoder interface, and will throw an EncoderException if the supplied object is not of type java.lang.String.
encode
in interface Encoder
obj
- Object to encodeEncoderException
- if the parameter supplied is not of type java.lang.Stringjava.lang.IllegalArgumentException
- if a character is not mappedsoundex(String)
public java.lang.String encode(java.lang.String source)
encode
in interface StringEncoder
source
- A String object to encodejava.lang.IllegalArgumentException
- if a character is not mappedsoundex(String)
public java.lang.String soundex(java.lang.String source)
In case a string is encoded into multiple codes (see branching rules), the result will contain all codes, separated by '|'.
Example: the name "AUERBACH" is encoded as both
Thus the result will be "097400|097500".
source
- A String object to encodejava.lang.IllegalArgumentException
- if a character is not mappedCopyright © 2010 - 2020 Adobe. All Rights Reserved