"did you mean" problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi, All!

My problem is with finding words (from a list of words) that closely
match the given word. Best example of it would be the "Did you mean" of
google.com when we misspell a word and google comes up with the correct

In my case, I have a list of words. A user searches for a word but
misspells it. The program should provide all the words (from the list)
that match closely (maybe, edit distance <= 2, see levenshtein()
function in PHP manual) to the searched word. One way to accomplish it
is to calculate the editing distance of the given word with each word in
the list and select those words from the list that are two or less
editing-distance apart from the given word. This method is well suited
when the number of words in the list is small. What could be done if the
number of words in the list is too large. I am almost sure there is a
better way to do it (google does! so does Aspell) but don't know how.

Any pointers in this direction are most welcome.


Re: "did you mean" problem

Quoted text here. Click to load it

You'll need to use one of PHP's spell checker extensions (such as
Enchant or pspell) to spell check the user's input and if there are
any errors pick the first matching suggestion that the spell checker
comes up with. Check the online docs for more information on the
extensions in question.

Site Timeline