Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a "Did you mean?" feature as used on Amazon and Google

Tags:

php

search


I have a website and I am using Google search widget on it. Now I would like to have, if possible, the feature "Do you mean:" as used on Amazon and Google. This feature would allow a user to search for a product and if the desired product does not exist then the search results will offer a suggestion. E.g. if a visitor is looking for a "Wonder Mop 3000", but the site is offering only "Wonder Mop 1000" then above the search results, the result will look like:

Did you mean: "Wonder Mop 1000"
---------------------------------------
Results for "Wonder Mop 3000"
...

Is this possible with google search or I will need a different search engine?

like image 691
Radi Avatar asked Aug 26 '11 14:08

Radi


1 Answers

Here is an excellent, accessible article by Peter Norvig, Director of Research at Google on how to implement the "did you mean" feature in a few lines of code. It's really a great read.

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

Essentially you will need a 'corpus' or list of valid searches, and given a search, you will try to come up with the 'most likely' correct search. At the bottom there are links to implementations in various languages including PHP, of course. Check it out :)

like image 184
nicolaskruchten Avatar answered Nov 02 '22 23:11

nicolaskruchten