您也许可以使用正则表达式,例如:
art_groups_arr.each do |art_gr_arr|
if n2.art_group.any? { |element|
/ормозн/ =~ element and /диск/ =~ element
} then non_original << n2 end
end
或者,您可以尝试声称实现 Smith-Waterman 算法的 fuzz_ball gem。
require 'fuzz_ball'
THRESHOLD_SCORE = 0.75
MATCHER = FuzzBall::Searcher.new [ 'Тормозной диск LPR' ]
def complies?( str )
matchdata = MATCHER.search str
return false if matchdata.nil? or matchdata.empty?
score = matchdata[0][:score]
puts "score is #{score}"
score > THRESHOLD_SCORE
end
art_groups_arr.each do |art_gr_arr|
if n2.art_group.any? { |element| complies? element } then
non_original << n2
end
end
为了'Диски тормозные LPR'
获得 score 0.861
,您必须调整阈值。