Ruby/Rails 中的模糊比较

发布于 2024-11-27 01:13:20 字数 299 浏览 0 评论 0原文

我一直在寻找一些在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

—━☆沉默づ 2024-12-04 01:13:20

看看并玩一下 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)

欲拥i 2024-12-04 01:13:20

看看这个 FuzzyMatch gem

它可能会帮助你。

Have a look on this FuzzyMatch gem

It may help you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文