Ruby gem for text comparison -


i looking gem can compare 2 strings (in case paragraphs of text) , able gauge likelihood similar in content (with perhaps few words rearranged, changed). believe uses similar when users submit questions.

i'd use diff::lcs:

>> require "diff/lcs" >> seq1 = "lorem ipsum dolor sit amet consequtor".split(" ") >> seq2 = "lorem ipsum dolor amet sit consequtor".split(" ") 1.9.3-p194 :010 > diff::lcs.diff(seq1, seq2).length  => 2 

it uses longest common subsequence algorithm (the method using lcs diff described on the wiki page).


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -