支持拼写错误的应用程序(搜索)
我正在创建一个简单的应用程序,这是第一次使用 SQLite。
我想要一个常规搜索框并在用户键入时显示结果(这可能吗)
以及如何为了使搜索能够支持拼写错误,如果我写“Canda”来找到我“Canada”、“Candy”或数据库中类似于搜索的任何内容
任何帮助或文献都会有所帮助
I'm creating a simple application, first time working with SQLite.
I want a regular search box and to display results as a user types (is this possible)
And how to make the search to be able to support misspellings, if i wrote "Canda" to find me "Canada","Candy" or whatever i have in the DB similar to the search
any help or literature will be helpful
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关于(1),你应该看看 UISearchDisplayController,简而言之,它将允许您在键入时轻松搜索和显示结果。
对于(2),我的第一个想法可能是代表数据模型中“可能的”拼写错误?此外,增加这个拼写错误列表也会很有趣——苹果自己的短信应用程序正在做类似的事情,这样它就能在你继续操作时从你的拼写错误中学习。
Concerning (1), you should take a look at UISearchDisplayController, in short it'll allow you to easily search and display results as you type.
For (2), my first thought would be to perhaps represent the "likely" misspellings in your data model? In addition it would be interesting to also augment this list of misspellings - Apple's own SMS app is doing something like this, so that it learns from your misspellings as you go along.
UISearchDisplayController 将在用户输入文本时启动搜索,从而不断缩小结果范围。
据我所知,尽管已多次请求该功能,但 SQLite 并不直接支持模糊匹配。
它需要一个引用复杂的算法才能有效地完成此操作,如这篇维基百科文章中详细介绍的。
PostgreSQL 存在一个名为 fuzzystrmatch 的模块,但它确实有其局限性,尤其是多字节字符串(如 UTF-8),它们是 SQLite 的本机字符串格式。这可能会给您一个可能的实现的提示。
UISearchDisplayController will kick of searches as the user types in text and thus narrowing the results down continously.
To my best of knowledge fuzzy matching is not directly supported in SQLite even though the feature have been requested numerous times.
It requires a quote complex algoritm to do this effectively as detailed in this Wikipedia article.
There exists a module called fuzzystrmatch for PostgreSQL, but it does have it's limitations, especially with multibyte strings (like UTF-8) which are the native string formats for SQLite. This might give you a hint of a possible implementation.