phpindexingphoneticsmetaphone

What are the practical usages of functions metaphone() and soundex() in PHP?


Metaphone and Soundex are phonetic algorithms for indexing strings by their English pronunciation.

Have you ever used functions metaphone() or soundex() that are present in the standard PHP library?

What for? What are real-life usages of these functions?


Solution

  • More generally, soundex and metaphone can be used to find strings that sound similar when pronounced out loud.

    This can be used beyond situations where you're just trying to find a "correct" spelling. It might be used, for example, to help spot an error like incorrect usage of a correctly-spelled word that sounds like the right one.

    Another attractive use is to try and find the correct name. When I tell someone my name is "Nicholas", there are at least two "alternative" spellings I see them try to use a lot: Nicolas and Nikolas. When they type it in and it doesn't find me in the database, soundex or metaphone might be used to say "There's no Nicolas Knight, but there is a Nicholas Knight".

    The degree to which these algorithms actually work, however, is somewhat debatable. They occasionally come up with rather strange results.