views:

41

answers:

2

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?

+2  A: 

You could use these when performing a spell-check. You could then easily spot that e.g. 'phorensics' is a good match for 'forensics'.

Will A
That happens to be a bad example for `soundex`, because the leading letter is always the first letter of the word, so `phorensics` is `P652` and `forensics` is `F652`
Michael Mrozek
D'oh. :) Good call - which leads me to telefone / telephone (which is probably another bad example depending on which language you speak!). How does metaphone handle my dodgy example?
Will A
+1  A: 

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.

Nicholas Knight