开发者

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 libr开发者_Python百科ary?

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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜