Skip to content

Commit

Permalink
Merge pull request #56 from ybiquitous/remove-deprecation-warnings-fr…
Browse files Browse the repository at this point in the history
…om-rakefile-and-benchmark

chore: use "similarity" methods over deprecated "distance" methods for rake tasks
  • Loading branch information
tonytonyjan authored Aug 28, 2024
2 parents f87fb57 + b8bbec0 commit ec51b6e
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 ec51b6e

Please sign in to comment.