Page 1 of 1

correcting misspelled words in a search input

Posted: Fri Mar 11, 2005 6:05 am
by Krabi
Hello,
I would like to optimize the search function on my website and implement a sort of correcting function for misspelled words.
If the string doesn't match any word in my mysql field, I begin to search "select * from mytable where field like '%_tring%'" and then s_ring, st_ing, etc... Then I search for %tring, s%ring, st%ing, etc...
Is this a good way to procede ? How can I make my script better ?
I've searched for tutorials or scripts-examples for functions like this with no results, if you know anything about this, I would really appreciate an answer!

WordNet

Posted: Fri Mar 11, 2005 6:34 am
by anjanesh
If you want a real good spell check you'll need a db containing words etc to do this efficiently.
You'll find an open source(? maybe just free) here :http://wordnet.princeton.edu/ but the MySQL conversion is done by another org : http://www.androidtech.com/html/wordnet-mysql-20.php
This way you can check and suggest like the way Google does.

Posted: Fri Mar 11, 2005 6:55 am
by Krabi
Thank you, but the website I'm working on is in swedish, I don't think there are such dictionnairies available...
I can add that I'm searching in short fields, like film-titles.

Posted: Sun Mar 13, 2005 4:35 am
by anjanesh
You can also try Pspell Functions - http://www.php.net/manual/en/ref.pspell.php
The only thing you need to get is pspell_config_data_dir -- location of language data files : http://www.php.net/manual/en/function.p ... ta-dir.php