4

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!

Thariq Shihipar
  • 1,072
  • 1
  • 12
  • 27
  • 2
    Sounds like a full text search solution might be better for you than a fuzzy search system. – mu is too short Jul 29 '11 at 02:29
  • Possibly, I already employ a full text search system though and it's not too good at ignoring extraneous words. Maybe that's a configuration problem though. – Thariq Shihipar Jul 29 '11 at 02:32
  • 1
    There's usually a "stop words" list that you can play with. – mu is too short Jul 29 '11 at 02:50
  • Perhaps, but it's not really that kind of 'stop word list'. They could be giving me extra information about the thing I'm searching for that I need to ignore, but there's no real pattern or list of words I can employ to do that. – Thariq Shihipar Jul 29 '11 at 23:08

2 Answers2

1

Have a look on this FuzzyMatch gem

It may help you.

RAJ
  • 9,697
  • 1
  • 33
  • 63
1

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)

jamesc
  • 12,423
  • 15
  • 74
  • 113