PHP 中函数 metaphone() 和 soundex() 的实际用法是什么?
Metaphone 和 Soundex 是根据字符串的英语发音对字符串进行索引的语音算法。
您是否曾经使用过函数 metaphone() 或 soundex() 存在于标准 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更一般地说,soundex 和 metaphone 可用于查找大声发音时听起来相似的字符串。
这可以在您只是试图找到“正确”拼写的情况之外使用。例如,它可以用来帮助发现错误,例如错误地使用了拼写正确但听起来正确的单词。
另一个有吸引力的用途是尝试找到正确的名称。当我告诉别人我的名字是“尼古拉斯”时,我看到他们至少尝试使用两种“替代”拼写:尼古拉斯和尼古拉斯。当他们输入它但在数据库中找不到我时,可能会使用 soundex 或变音位来表示“没有尼古拉斯·奈特,但有一个尼古拉斯·奈特”。
然而,这些算法的实际工作程度却存在争议。他们偶尔会得出相当奇怪的结果。
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.
您可以在执行拼写检查时使用它们。然后您可以很容易地发现,例如“phorensics”与“forensics”非常匹配。
You could use these when performing a spell-check. You could then easily spot that e.g. 'phorensics' is a good match for 'forensics'.