How to implement Google-style "Did you mean"? [duplicate]
Possible Duplicate:
How do you implement a “Did you mean”?
Is there 开发者_StackOverflow中文版a web service or public api that would allow your app to to check for obvious misspellings in the names of famous people:
Mikul Jaxon
Prinz Charlz
Britnie Speers
Or would this require building a database of your own?
I'd like to have something like Google's "Did you mean ... ?
" feature, where they suggest corrections when you misspell something. In my case I just need it for famous people.
you should check out the fuziness search of apache solr/lucene. maby a fuzzy search or autocompletion is a better apporach as it will be faster.
however the easiest and still very fast implementation i have seen was to build up an index of token documenst that are weighted by relevance.
then you can run your query in "or-conjunction" against that table and fetch the results of how many tokens your string consists.
then you can easily determine which word corresponds to the words in your query by calculating the Levenshtein_distance.
精彩评论