Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby-on-Rails的邻近匹配_Ruby On Rails_Ruby_Similarity - Fatal编程技术网

Ruby-on-Rails的邻近匹配

Ruby-on-Rails的邻近匹配,ruby-on-rails,ruby,similarity,Ruby On Rails,Ruby,Similarity,我正在开发一个应用程序,在这个应用程序中,我必须“匹配”大量字符串,以确保不同单词和短语的存在。不过,我现在使用的常规方法必须得到100%的匹配才能实现: 例如: string1 = "This education takes (around) 2 years." string2 = "It will take around 2 years to finish this education." 当然,我可以为它编写一个标准的regexp来匹配这两个字符串,但通常我不知道要输入的字符串的内容 在

我正在开发一个应用程序,在这个应用程序中,我必须“匹配”大量字符串,以确保不同单词和短语的存在。不过,我现在使用的常规方法必须得到100%的匹配才能实现:

例如:

string1 = "This education takes (around) 2 years."
string2 = "It will take around 2 years to finish this education."
当然,我可以为它编写一个标准的regexp来匹配这两个字符串,但通常我不知道要输入的字符串的内容

在这种情况下,有没有办法匹配邻近性?所以我可以写一个匹配条件,例如,定义接近度必须至少为80%才能为真

另外,我正在运行Ruby 2.0.0-p353和Rails 4.0.1,也许gem可以帮助你。它实现了许多不同的算法,您可以进行比较和使用


或者,看看,它只实现了一个算法,而且可能更容易开始:)

这是关于语义距离的,广泛的主题我知道如何处理它吗?也许有个Rubygem?我去看看。谢谢