长查询列表中的模糊匹配 API
我有一个应用程序,可以让人们提出预定义的查询。然而,此类查询的列表太长。因此,当前的方法是让用户在搜索框中输入单词,然后向他们显示查询列表中可能的匹配项。 (非常像谷歌的“你是说”功能。)
Java 中有可用的 API 吗?我应该能够提供查询列表。 API 应提供模糊匹配功能,这样拼写错误就不会产生影响。 (这就是为什么精确的字符串匹配算法是不够的)
I have an application which lets people ask predefined queries. However, the list of such queries is too long. Hence, the current approach is to let users enter a word in the search box and then show them the likely matches from the list of queries. ( Very much like google's "Did you mean" feature.)
Is there an API in Java available for this? I should be able to supply the list of queries. The API should provide a fuzzy match capability, so that incorrect spellings do not matter. ( That is why an exact String matching algorithm is not sufficient)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这里的神奇词可能是“正则表达式”——任何你可以建模的东西作为有限状态机可以用正则表达式来完成。
如果做不到这一点,您可以查看“数字搜索树”或“尝试”。
The magic word here may be "regular expression" -- anything you can model as a finite state machine can be done with regular expressions.
Failing that, you might look into "digital search trees" or "tries".
我可以建议的一些 API 是:
类似的问题:
Some of the API's i can suggest are:
Similar SO Questions:
也许使用 Soundex 或导数的概率算法会起作用? http://en.wikipedia.org/wiki/Soundex
Perhaps a probabilistic algorithm using Soundex or a derivative would work? http://en.wikipedia.org/wiki/Soundex
找到了 Peter Norvig 的拼写纠正算法的 Java 实现。
有点过时,但适合入门。
Found these Java implementation of Peter Norvig's spell correction algorithm.
A bit dated, but good for getting started.