Skip to content

Instantly share code, notes, and snippets.

@chintanparikh
Created December 27, 2013 22:05
Show Gist options
  • Save chintanparikh/8153269 to your computer and use it in GitHub Desktop.
Save chintanparikh/8153269 to your computer and use it in GitHub Desktop.
def jaccard_index(n, article_one, article_two)
first = article_one.split(' ').each_cons(n).to_a
second = article_two.split(' ').each_cons(n).to_a
(first & second).length.to_f / ((first.length + second.length).to_f / 2).abs.to_f
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment