Google 搜索中拼写错误纠正背后的算法
我注意到如果我在谷歌搜索栏中输入错误,它很可能会为我纠正。
就像,如果我输入“incredible”,它会建议“incredible”,或者对于“stackovflow”,它将建议“stackoverflow”。
这种算法的核心思想是什么?
I notice if I make a typo in Google search bar, it is very likely to correct it for me.
Like, if I type "incerdible", it will suggest "incredible", or for "stackovflow", it will be "stackoverflow".
What is the core idea of such algorithm?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个解释,以及一些包含更多详细信息的链接:
http://norvig.com/spell- Correct.html
Here is an explanation, and some more links with further details:
http://norvig.com/spell-correct.html
有很多算法可以解决这个问题。核心算法是计算两个单词之间的差异。你可以看一下 Levenshtein distance,这是一个很好的算法。
如果你想使用类似的东西,你可以使用一些 npm 包,如下所示:
https:// www.npmjs.com/package/typo- Correction
There are many algorithms to solve that problem. The core algorithm is to calculate the difference between two words. You can take a look at Levenshtein distance, this is a great algorithm to do that.
If you want to use something like that, you can use some npm package like this:
https://www.npmjs.com/package/typo-correction