I'm trying to diff two strings by phrase, similar to the way that StackOverflow diffs the two strings on the version edits page. What would be an algorithm to do this? Are there gems, or other standard libraries that accomplish this?
EDIT: I've seen other diffing algorithms (Differ with Ruby) and they seem to result in the following:
>> o = 'now is the time when all good men.'
>> p = 'now some time the men time when all good men.'
>> Differ.diff_by_word(o,p).format_as(:html)
=> "now <del class=\"differ\">some</del><ins class=\"differ\">is</ins>
<del class=\"differ\">time </del>the <del class=\"differ\">men </del>time
when all good men."
Note how the words are diffed on a per word basis? I'd like some way of diffing more by phrase, so the above code output:
=> "now <del class=\"differ\">some time the men</del><ins class=\"differ\">is
the</ins> time when all good men."
Am I hoping for too much?