Hello, I want to add the 'did you mean' feature (like on Google) on my shareware site, where a lot of users have mistypes, and they get 0 results... so they exit the site very fast. Do you have any idea how I could implement such a thing? Does it require a dictionary or something? I found some scripts, but none of them gave relevant results... just stupid, irrelevant suggestions. Any help would be appreciated...

I heard Python might be suitable for such things, but I would'n mint to see a non-Python solution :)

Thanks, Lucy

Well, that depends upon what you mean ... :)

Can you keep track of those queries where the user gets back 0 results? Just save the request to a file. Then periodically review the file yourself and manually add the definitions. Python dictionaries could be used there.

So you might see "dvitops" and realize that the user was asking for "dvi2ps", and so set up a dictionary entry didyoumean['dvitops']='dvi2ps' and go from there.

Obviously Google doesn't do it this way but they have the luxury of being able to observe queries one after another from the same person. And they have a huge universe of terms to worry about. You don't have either. You have a relatively small set of names, and therefore a relatively small set of possible mistakes. After the first few dozen entries your didyoumean[] dictionary will grow slowly and your hit rate should increase.

I can keep track of the searches, in fact I already save them, and their number. but when you have a large number of searches, manual suggestions is not a solutin...

i now try to implement levenstein, soundex, and yahoo api... hopefully one will do the task :)

OK, the winner is Yahoo Spelling Suggestion (which uses Yahoo API). This gives your site the possibility to suggest exactly what Yahoo Search suggests :cool: Awesome, I would say!

Here is a short summary about using it, if you guys want to use it too: it requires a Yahoo API key, which can be got free. It is limited to 5000 queries per day, so I suggest caching the suggestion (which I implemented, as my site has more then 5000 searches per day). The page returned by Yahoo needs to be parsed, and see if there is a suggestion given. This is a page that gives a suggestion, this is one that has no suggestion.

You can see it live on my shareware site: http://www.coredownload.com/ try some mistypes, like "enail backup", "rgistry cleaner" or whatever you want. I also implemented a function to make bold italic the words that are different between the search query and the suggestion from Yahoo. ;)

If you need assistance on implementing this on your site, let me know.

Thanks, Lucy

I just tried it. Very nice indeed. Thanks for sharing your solution.