Sha256: df2a60721be9f9dfbb3bd16a66f552b85176be3553f7eb31f43ad2c1ef0ab779
Contents?: true
Size: 1.6 KB
Versions: 4
Compression:
Stored size: 1.6 KB
Contents
require "bundler/gem_tasks" require "rake/extensiontask" Rake::ExtensionTask.new("jaro_winkler") do |ext| ext.lib_dir = "lib/jaro_winkler" end task :benchmark do ROOT_PATH = File.expand_path('..', __FILE__) LIB_PATH = File.join(ROOT_PATH, 'lib') BENCHMARK_PATH = File.join(ROOT_PATH, 'benchmark') Dir[File.join(BENCHMARK_PATH, '*.rb')].each do |path| output_path = File.join(BENCHMARK_PATH, File.basename(path, '*.rb').sub('.rb', '.txt')) cmd = "RUBYLIB=#{LIB_PATH} ruby #{path} > #{output_path}" puts cmd system(cmd) end end task :compare do require 'jaro_winkler' require 'fuzzystringmatch' require 'hotwater' require 'amatch' @ary = [['henka', 'henkan'], ['al', 'al'], ['martha', 'marhta'], ['jones', 'johnson'], ['abcvwxyz', 'cabvwxyz'], ['dwayne', 'duane'], ['dixon', 'dicksonx'], ['fvie', 'ten']] table = [] table << %w[str_1 str_2 jaro_winkler fuzzystringmatch hotwater amatch] 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)] end col_len = [] table.first.length.times{ |i| col_len << table.map{ |row| row[i].to_s.length }.max } table.first.each_with_index{ |title, i| "%-#{col_len[i]}s" % title } table.each_with_index do |row| row.each_with_index do |col, i| row[i] = "%-#{col_len[i]}s" % col.to_s end end table.each{|row| puts row.join(' | ')} end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
jaro_winkler-1.2.8 | Rakefile |
jaro_winkler-1.2.7 | Rakefile |
jaro_winkler-1.2.6 | Rakefile |
jaro_winkler-1.2.5 | Rakefile |