Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,922 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,788 people online right now. Registration is fast and FREE... Join Now!




The "did you mean" feature

 
Reply to this topicStart new topic

The "did you mean" feature, how to do it

lucym
20 Mar, 2008 - 12:52 AM
Post #1

New D.I.C Head
*

Joined: 20 Mar, 2008
Posts: 3

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...
Thanks, Lucy

User is offlineProfile CardPM
+Quote Post

spearfish
RE: The "did You Mean" Feature
20 Mar, 2008 - 05:31 AM
Post #2

Monkey in Training
Group Icon

Joined: 10 Mar, 2008
Posts: 746



Thanked: 2 times
Dream Kudos: 225
My Contributions
What you can do is add in a dictionary, and then check the query against the dictionary to see if they're similar.

I would compare via either the Metaphone or the Levenshtein algorithms.
User is offlineProfile CardPM
+Quote Post

lucym
RE: The "did You Mean" Feature
20 Mar, 2008 - 07:19 AM
Post #3

New D.I.C Head
*

Joined: 20 Mar, 2008
Posts: 3

QUOTE(spearfish @ 20 Mar, 2008 - 06:31 AM) *

What you can do is add in a dictionary, and then check the query against the dictionary to see if they're similar.

I would compare via either the Metaphone or the Levenshtein algorithms.


yes, i am now trying the Levenstein and Soundex.
User is offlineProfile CardPM
+Quote Post

spearfish
RE: The "did You Mean" Feature
20 Mar, 2008 - 01:09 PM
Post #4

Monkey in Training
Group Icon

Joined: 10 Mar, 2008
Posts: 746



Thanked: 2 times
Dream Kudos: 225
My Contributions
Metaphone generally is more accurate than Soundex, or at least that's what the PHP book I have says.
User is offlineProfile CardPM
+Quote Post

lucym
RE: The "did You Mean" Feature
22 Mar, 2008 - 07:53 AM
Post #5

New D.I.C Head
*

Joined: 20 Mar, 2008
Posts: 3

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. wink2.gif

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

Thanks, Lucy
User is offlineProfile CardPM
+Quote Post

spearfish
RE: The "did You Mean" Feature
22 Mar, 2008 - 10:43 AM
Post #6

Monkey in Training
Group Icon

Joined: 10 Mar, 2008
Posts: 746



Thanked: 2 times
Dream Kudos: 225
My Contributions
Cool!
User is offlineProfile CardPM
+Quote Post

brandon99337
RE: The "did You Mean" Feature
22 Mar, 2008 - 02:19 PM
Post #7

D.I.C Head
**

Joined: 14 Feb, 2008
Posts: 133



Thanked: 1 times
My Contributions
That's awesome! I need to try that out sometime!
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 10:14PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month