The OpenD Programming Language

soundexer

Soundex algorithm.

The Soundex algorithm converts a word into 4 characters based on how the word sounds phonetically. The idea is that two spellings that sound alike will have the same Soundex value, which means that Soundex can be used for fuzzy matching of names.

  1. char[4] soundexer(Range str)
  2. char[4] soundexer(Range str)
    char[4]
    soundexer
    (
    Range
    )
    (
    auto ref Range str
    )

Parameters

str Range

String or InputRange to convert to Soundex representation.

Return Value

Type: char[4]

The four character array with the Soundex result in it. The array has zero's in it if there is no Soundex representation for the string.

Examples

assert(soundexer("Gauss") == "G200");
assert(soundexer("Ghosh") == "G200");

assert(soundexer("Robert") == "R163");
assert(soundexer("Rupert") == "R163");

assert(soundexer("0123^&^^**&^") == ['\0', '\0', '\0', '\0']);

See Also

Wikipedia, $(LUCKY The Soundex Indexing System) soundex

Note: Only works well with English names.

Meta