Function Block SOUNDEX

The Function Block SOUNDEX calculates the phonetic similarity of a string.

Soundex values have the property that similarly pronounced words produce the same Soundex value. This can be used for database searches when you know the pronunciation but not the exact spelling. The function Soundex returns a four-character string, starting with a letter.

Input STR

The input defines the string to be calculated.

Output

Returns a string with the Soundex code.

Basic Rules

Each Soundex code consists of one letter followed by three digits, e.g., A532 for Antcas. If the word to be encoded has so many letters that more digits could be generated, it is truncated after the third digit. If the word has too few letters, the last digits are filled with zeros. The Asian name Lee is therefore encoded as L000.

Digit Represented Letters
1 B, F, P, V
2 C, G, J, K, Q, S, X, Z
3 D, T
4 L
5 M, N
6 R

The vowels A, E, I, O and U and the consonants H, W and Y are to be ignored except for the first character. Additionally, for the German language, it can be defined that: The umlauts Ä, Ö and Ü are to be ignored, the "sharp S" ß is encoded like the simple S.

If multiple consecutive letters in the original string have the same Soundex code, it appears only once in the result, from abfx becomes approximately A120 (a remains because it is the first letter, b and f both yield the same code 1, x yields 2, a zero is appended at the end to obtain four characters).

In practical application of the Soundex method, two points are mainly criticized: On the one hand, it is very oriented towards the English language, on the other hand, it only offers a very rough analysis.

Nevertheless, it should be noted that the algorithm presented is probably the most frequently used for phonetic search. This has certainly been contributed to by the fact that a corresponding PL/SQL standard command was implemented in the Oracle database at a very early stage.