'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?



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jim