Skip to content

Commit

Permalink
chore: use "similarity" methods over deprecated "distance" methods fo…
Browse files Browse the repository at this point in the history
…r rake tasks

This change removes a lot of deprecation warnings from `rake compare` and `rake benchmark` executions.

It follows up to the commit:
d662816
  • Loading branch information
ybiquitous committed May 16, 2024
1 parent d662816 commit b8bbec0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ task compare: :compile do
table << %w[--- --- --- --- --- ---]
jarow = FuzzyStringMatch::JaroWinkler.create(:native)
@ary.each do |str_1, str_2|
table << ["\"#{str_1}\"", "\"#{str_2}\"", JaroWinkler.distance(str_1, str_2).round(4), jarow.getDistance(str_1, str_2).round(4), Hotwater.jaro_winkler_distance(str_1, str_2).round(4), Amatch::Jaro.new(str_1).match(str_2).round(4)]
table << ["\"#{str_1}\"", "\"#{str_2}\"", JaroWinkler.similarity(str_1, str_2).round(4), jarow.getDistance(str_1, str_2).round(4), Hotwater.jaro_winkler_distance(str_1, str_2).round(4), Amatch::Jaro.new(str_1).match(str_2).round(4)]
end
col_len = []
table.first.length.times{ |i| col_len << table.map{ |row| row[i].to_s.length }.max }
Expand Down
4 changes: 2 additions & 2 deletions benchmark/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
end

if version >= Gem::Version.new('1.4.0')
jobs[:ascii] = -> { n.times { SAMPLES[:ascii].each { |str1, str2| JaroWinkler.distance(str1, str2) } } }
jobs[:utf8] = -> { n.times { SAMPLES[:utf8].each { |str1, str2| JaroWinkler.distance(str1, str2) } } }
jobs[:ascii] = -> { n.times { SAMPLES[:ascii].each { |str1, str2| JaroWinkler.similarity(str1, str2) } } }
jobs[:utf8] = -> { n.times { SAMPLES[:utf8].each { |str1, str2| JaroWinkler.similarity(str1, str2) } } }
end

# rehearsal
Expand Down
2 changes: 1 addition & 1 deletion benchmark/native.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

Benchmark.bmbm do |x|
x.report "jaro_winkler (#{`git rev-parse --short HEAD`.chop!})" do
n.times { SAMPLES[:ascii].each { |str1, str2| JaroWinkler.distance(str1, str2) } }
n.times { SAMPLES[:ascii].each { |str1, str2| JaroWinkler.similarity(str1, str2) } }
end

x.report gem_name_with_version('fuzzy-string-match') do
Expand Down
2 changes: 1 addition & 1 deletion benchmark/pure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Benchmark.bmbm do |x|
x.report "jaro_winkler (#{`git rev-parse --short HEAD`.chop!})" do
n.times { SAMPLES[:ascii].each { |str1, str2| JaroWinkler.distance(str1, str2) } }
n.times { SAMPLES[:ascii].each { |str1, str2| JaroWinkler.similarity(str1, str2) } }
end

x.report gem_name_with_version('fuzzy-string-match') do
Expand Down

0 comments on commit b8bbec0

Please sign in to comment.