Sha256: de17b6ff7cae7e7ed400063fe7c00b514d629d90b58ba0a448b35b3540fea024
Contents?: true
Size: 1.4 KB
Versions: 9
Compression:
Stored size: 1.4 KB
Contents
# encoding: utf-8 require 'spec_helper' module RuboCop module StringUtil describe Jaro do { %w(foo foo) => 1.000, %w(foo bar) => 0.000, %w(martha marhta) => 0.944, %w(dwayne duane) => 0.822 }.each do |strings, expected| context "with #{strings.first.inspect} and #{strings.last.inspect}" do subject(:distance) { Jaro.distance(*strings) } it "returns #{expected}" do expect(distance).to be_within(0.001).of(expected) end end end end describe JaroWinkler do # These samples are derived from Apache Lucene project. # https://github.com/apache/lucene-solr/blob/lucene_solr_4_9_0/lucene/suggest/src/test/org/apache/lucene/search/spell/TestJaroWinklerDistance.java { %w(al al) => 1.000, %w(martha marhta) => 0.961, %w(jones johnson) => 0.832, %w(abcvwxyz cabvwxyz) => 0.958, %w(dwayne duane) => 0.840, %w(dixon dicksonx) => 0.813, %w(fvie ten) => 0.000 }.each do |strings, expected| context "with #{strings.first.inspect} and #{strings.last.inspect}" do subject(:distance) { JaroWinkler.distance(*strings) } it "returns #{expected}" do expect(distance).to be_within(0.001).of(expected) end end end end end end
Version data entries
9 entries across 9 versions & 2 rubygems