public class DaitchMokotoffSoundex extends 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 |
---|---|
Object |
encode(Object obj)
Encodes an Object using the Daitch-Mokotoff soundex algorithm without branching.
|
String |
encode(String source)
Encodes a String using the Daitch-Mokotoff soundex algorithm without branching.
|
String |
soundex(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 Object encode(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.StringIllegalArgumentException
- if a character is not mappedsoundex(String)
public String encode(String source)
encode
in interface StringEncoder
source
- A String object to encodeIllegalArgumentException
- if a character is not mappedsoundex(String)
public String soundex(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 encodeIllegalArgumentException
- if a character is not mappedCopyright © 2002–2019 The Apache Software Foundation. All rights reserved.