SnTT: Kölner Phonetik - das bessere Soundex?!

by Thomas Bahn,
assono GmbH, Standort Kiel,


Show-n-Tell Thursday The Kölner Phonetik (Cologne Phonetics?) is a phonetical algorithm, which assigns words a string of digits from 0 to 8. Similar sounding words get the same string assigned, thus it's possible to find similar sounding words, e. g. names in a list. It's like the Soundex algorithm, but "tuned" for the German language. It was published 1969 by Postel.

@Soundex is a function implemented in the formula language and is used e. g. in the Domino directory to look for similar sounding names (see first column of the ($Users) view). But Soundex doesn't work for German as well as for English, since Germans pronounce letters differently. Therefore Mr. Postel developed a better suiting algorithm: the Kölner Phonetik.


On first sight, the implementation seems pretty forward, but the devil is in the details. Therefore I was happy to find an implementation of the algorithm with Visual Basic  (German) in the vb@rchiv as a starting point

The translation into LotusScript is easy, because no specialities of VB were used.

More relevant would be an implementation in formula language, usable in computed fields and column formulas. I have written this formula:


_input := @Prompt([OkCancelEdit]; "Kölner Phonetik"; "Enter name"; "");

_trimmed := @Trim(_input);
_lower := @LowerCase(_trimmed);
_replacedSpecialChars := @ReplaceSubstring(_lower;
        "ph" : "ä" : "ö" : "ü" : "ß"; "f" : "a" : "o" : "u" : "ss");
_withMarkers := "#" + _replacedSpecialChars + "#";

_convertedToNumber := "";
@For(_position := 1; _position < @Length(_withMarkers) - 1; _position := _position + 1; @Do(
    _previous := @Middle(_withMarkers; _position - 1; 1);
    _current := @Middle(_withMarkers; _position; 1);
    _next := @Middle(_withMarkers; _position + 1; 1);

    _convertedToNumber := _convertedToNumber + @If(
        _position = 1;
        @If(
            (_current = "a" : "e" : "i" : "j" : "y" : "o" : "u"); "0";
            (_current = "c") & (_next = "a" : "o" : "u" : "h" : "k" : "x" :"q" : "l" : "r"); "4";
            (_current = "d" : "t") & (_next = "s" : "c" : "z"); "8";
            (_previous = "c" : "k" : "q") & _current = "x"; "8";
            (_current = "x"); "48";
            (_previous = "s") & (_current = "c" : "z"); "8";
            (_current = "h"); "-";
            (_current = "b" : "p"); "1";
            (_current = "d" : "t"); "2";
            (_current = "f" : "v" : "w"); "3";
            (_current = "g" : "k" : "q"); "4";
            (_current = "l"); "5";
            (_current = "m" : "n"); "6";
            (_current = "r"); "7";
            (_current = "c" : "s" : "z"); "8";
            "?"
        );
        @If(
            (_current = "d" : "t") & (_next = "s" : "c" : "z"); "8";
            (_previous = "c" : "k" : "q") & _current = "x"; "8";
            (_current = "x"); "48";
            (_previous = "s") & (_current = "c" : "z"); "8";
            (_current = "c") & (_next = "a" : "o" : "u" : "h" : "k" : "x" :"q"); "4";
            (_current = "h"); "-";
            (_current = "a" : "e" : "i" : "j" : "y" : "o" : "u"); "0";
            (_current = "b" : "p"); "1";
            (_current = "d" : "t"); "2";
            (_current = "f" : "v" : "w"); "3";
            (_current = "g" : "k" : "q"); "4";
            (_current = "l"); "5";
            (_current = "m" : "n"); "6";
            (_current = "r"); "7";
            (_current = "c" : "s" : "z"); "8";
            "?"
        )
    )
));

_withoutH := @ReplaceSubstring(_convertedToNumber; "-"; "");

_zerosRemoved := @If(
    @Begins(_withoutH; "0");
    "0" + @ReplaceSubstring(_withoutH; "0"; "");
    @ReplaceSubstring(_withoutH; "0"; "")
);

_dublicatesRemoved := @Left(_zerosRemoved; 1);
@For(_position := 2; _position <= @Length(_zerosRemoved); _position := _position + 1;
    _dublicatesRemoved := _dublicatesRemoved + @ReplaceSubstring(
        @Middle(_zerosRemoved; _position - 1; 1); @Right(_dublicatesRemoved; 1); ""
    )
);

@Prompt([OK]; "Kölner Phonetik"; _input + " converts to " + _dublicatesRemoved)

Technical article IBM Notes IBM Notes Traveler Development

Sie haben Fragen zu diesem Artikel? Kontaktieren Sie uns gerne: blog@assono.de

Do you want an individual solution? Contact us

More interesting entries

Any questions? Contact us.

If you want to know more about our offers, you can contact us at any time. There are several ways to contact us for a non-binding first consultation.

We don’t sell your data. 100% guaranteed. See: Privacy Policy
assono GmbH

Location Kiel (headquarters)
assono GmbH
Lise-Meitner-Straße 1–7
24223 Schwentinental

Location Hamburg
assono GmbH
Bornkampsweg 58
22761 Hamburg

Phone numbers:
Human resources department: +49 4307 900 407
Technical department: +49 4307 900 403
Marketing department: +49 4307 900 402

E-Mail adresses:
contact@assono.de
bewerbung@assono.de