How to do advanced string comparison in Ruby?

一个人想着一个人 提交于 2019-11-29 10:23:02

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/4761793/how-to-do-advanced-string-comparison-in-ruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!