What's the idea behind suggesting a correct keyword if a non-exist keyword was queried.
For example, if I have this data in a database:
Test
Best
Win
etc..
Suppose the user entered "Tist", My program should display do you mean "Test". Also, if "Wen" is entered, "win" should be display as an autosuggestion.
well, you'd need a complete dictionary.
if you have that, you can check it for the entered word. if it's not there, levenstein() might get you close, but it'll take a long time to do a test like that, i think
well, look at levenstein(). it'll help a lot. you won't need a dictionary if you're only testing against words in your db.
yeah, i think you'd have to. you'd do a query for the fields that contain the keywords, and put them in an array. it's another DB hit, but i think it's all you can do, unless you hard code all the words in.
you could have a cron job run a script that generates a php file that is an array declaration containing all of the keywords. it would run every day or hour or so, then include that file 'array declaration file' from your script.
however, i don't know if it's faster to include a file, or to query the database.
Bookmarks