4

I am trying to compare 2 paragraphs of strings the output of which has to be the percentage of similarity.

I have tried doing this using the diff method and some Natural Language Processing tools

Is there a better way of doing this in ruby?

Avinasha Shastry
  • 822
  • 1
  • 8
  • 21
  • possible duplicate of [diff a ruby string or array](http://stackoverflow.com/questions/80091/diff-a-ruby-string-or-array) – sawa May 23 '11 at 08:23

2 Answers2

11

You may want to try the Levenshtein string distance algorithm for this. http://rubygems.org/gems/text has an implementation of this along with other helpful string comparison utils.

Michael Papile
  • 6,836
  • 30
  • 30
1

See my similar Question here what I needed but did not know what it was called was a Levenshtein distance algorithm

Community
  • 1
  • 1
Paul Whelan
  • 16,574
  • 12
  • 50
  • 83