如何实现Google式的“你是说”吗?
可能的重复:
如何实现“您是说”吗? < /p>
是有一个 Web 服务或公共 API 可以让您的应用程序检查名人姓名中是否存在明显的拼写错误:
Mikul Jaxon
Prinz Charlz
Britnie Speers
或者这是否需要构建您自己的数据库?
我想要类似 Google 的“您的意思是……吗?
”功能,当您拼写错误时,他们会建议更正。就我而言,我只需要名人。
Possible Duplicate:
How do you implement a “Did you mean”?
Is there 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该检查 apache solr/lucene 的模糊搜索。
也许模糊搜索或自动完成是更好的方法,因为它会更快。
然而,我见过的最简单且仍然非常快的实现是建立一个按相关性加权的令牌文档索引。
然后您可以针对该表在“或连接”中运行查询并获取字符串包含多少个标记的结果。
那么您可以通过计算 Levenshtein_distance 轻松确定哪个单词对应于查询中的单词。
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.