Ruby/Rails 中的模糊比较
我一直在寻找一些在 Rails 中进行模糊比较的好选择。
本质上,我有一组字符串,我想将它们与数据库中的某些字符串进行比较,并且我想获得最接近的字符串(如果适用)。在这种特殊情况下,我对检测无序/拼写错误的字母不太感兴趣,而是忽略无关单词(额外信息、标点符号、诸如:the、and、it 等单词)并挑选出最佳匹配。这些字符串的长度通常在 2-7 个单词之间。
您建议最好的宝石/方法是什么?我看过 amatch (http://flori.github.com/amatch/doc/index.html),但我想知道还有什么。
谢谢!
I was looking for some good options for fuzzy comparison in Rails.
Essentially, I have a set of strings that I'd like to compare against some strings in my database and I'd like to get the closest one if applicable. In this particular case, I'm not so interested in detecting letters out of order/mis-spellings, but rather the ability to ignore extraneous words (extra information, punctuation, words like: the, and, it etc) and pick out the best match. These strings will usually be somewhere between 2-7 words long.
What would you suggest is the best gem/method of doing that? I've looked at amatch (http://flori.github.com/amatch/doc/index.html) but I was wondering what else was out there.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看并玩一下 Thinking Sphinx http://freelancing-god.github.com/ts /zh/
我可以衷心推荐它
这里还有一个关于如何使用它的精彩 Railscast
http://railscasts.com/episodes/120 -thinking-sphinx
否则使用 ARel - 但你必须实现你自己的模糊逻辑(我不推荐)
Have a look and a play with Thinking Sphinx http://freelancing-god.github.com/ts/en/
I can heartily recommend it
There is also a superb Railscast on how to use it here
http://railscasts.com/episodes/120-thinking-sphinx
Otherwise use ARel - but you are going to have to implement your own fuzzy logic (Not something I'd recommend)
看看这个 FuzzyMatch gem
它可能会帮助你。
Have a look on this FuzzyMatch gem
It may help you.