MCPcopy Index your code
hub / github.com/apache/commons-codec / Soundex

Class Soundex

src/main/java/org/apache/commons/codec/language/Soundex.java:30–333  ·  view source on GitHub ↗

Encodes a string into a Soundex value. Soundex is an encoding used to relate similar names, but can also be used as a general purpose scheme to find word with similar phonemes. This class is thread-safe. Although not strictly immutable, the mutable fields are not actually used.

Source from the content-addressed store, hash-verified

28 * Although not strictly immutable, the mutable fields are not actually used.</p>
29 */
30public class Soundex implements StringEncoder {
31
32 /**
33 * The marker character used to indicate a silent (ignored) character.
34 * These are ignored except when they appear as the first character.
35 * <p>
36 * Note: the {@link #US_ENGLISH_MAPPING_STRING} does not use this mechanism
37 * because changing it might break existing code. Mappings that don't contain
38 * a silent marker code are treated as though H and W are silent.
39 * <p>
40 * To override this, use the {@link #Soundex(String, boolean)} constructor.
41 * @since 1.11
42 */
43 public static final char SILENT_MARKER = '-';
44
45 /**
46 * This is a default mapping of the 26 letters used in US English. A value of {@code 0} for a letter position
47 * means do not encode, but treat as a separator when it occurs between consonants with the same code.
48 * <p>
49 * (This constant is provided as both an implementation convenience and to allow Javadoc to pick
50 * up the value for the constant values page.)
51 * <p>
52 * <b>Note that letters H and W are treated specially.</b>
53 * They are ignored (after the first letter) and don't act as separators
54 * between consonants with the same code.
55 */
56 // ABCDEFGHIJKLMNOPQRSTUVWXYZ
57 public static final String US_ENGLISH_MAPPING_STRING = "01230120022455012623010202";
58
59 /**
60 * This is a default mapping of the 26 letters used in US English. A value of {@code 0} for a letter position
61 * means do not encode.
62 *
63 * @see Soundex#Soundex(char[])
64 */
65 private static final char[] US_ENGLISH_MAPPING = US_ENGLISH_MAPPING_STRING.toCharArray();
66
67 /**
68 * An instance of Soundex using the US_ENGLISH_MAPPING mapping.
69 * This treats H and W as silent letters.
70 * Apart from when they appear as the first letter, they are ignored.
71 * They don't act as separators between duplicate codes.
72 *
73 * @see #US_ENGLISH_MAPPING_STRING
74 */
75 public static final Soundex US_ENGLISH = new Soundex();
76
77 /**
78 * An instance of Soundex using the Simplified Soundex mapping, as described here:
79 * http://west-penwith.org.uk/misc/soundex.htm
80 * <p>
81 * This treats H and W the same as vowels (AEIOUY).
82 * Such letters aren't encoded (after the first), but they do
83 * act as separators when dropping duplicate codes.
84 * The mapping is otherwise the same as for {@link #US_ENGLISH}
85 * <p>
86 * @since 1.11
87 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…