Gem 发现一个 clone PHP similar_text 的组件。

mimosa · October 23, 2012 · Last by itlodge replied at January 06, 2016 · 2923 hits
require 'similar_text'

item1 = '相宜本草INOHERN 日夜润白精华霜(日霜+晚霜)50g*2'
item2 = '相宜本草日夜润白精华霜(日霜+晚霜)50g*2'
item1.similar(item2)
 # => 90.47619047619048
item1.similar_chars(item2)
 # => 38

对比两句话的相似度。

phash 算法还可以计算非文本的相似度: http://rubylution.herokuapp.com/topics/15

这个算法就是太慢了

You need to Sign in before reply, if you don't have an account, please Sign up first.