Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm behind typo corrections in Google Search

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?

like image 352
xiaohan2012 Avatar asked Sep 25 '11 02:09

xiaohan2012


2 Answers

Here is an explanation, and some more links with further details:

http://norvig.com/spell-correct.html

like image 142
K-ballo Avatar answered Dec 24 '22 13:12

K-ballo


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

like image 42
Jim Avatar answered Dec 24 '22 13:12

Jim