lib/jaro_winkler.rb in jaro_winkler-1.3.1 vs lib/jaro_winkler.rb in jaro_winkler-1.3.2.beta

- old
+ new

@@ -2,11 +2,11 @@ require 'jaro_winkler/adjusting_table' require 'jaro_winkler/jaro_winkler.so' unless JaroWinkler.fallback? module JaroWinkler module_function def jaro_distance s1, s2, options = {} - options = {adj_table: false}.merge options + options[:adj_table] length1, length2 = s1.length, s2.length # Guarantee the length order if s1.length > s2.length s1, s2 = s2, s1 length1, length2 = length2, length1 @@ -50,10 +50,10 @@ similarity += sim_matches / 10 if options[:adj_table] matches == 0 ? 0 : (similarity / length1 + similarity / length2 + (matches - transpositions) / matches) / 3.0 end def r_distance s1, s2, options = {} - options = {weight: 0.1, threshold: 0.7, ignore_case: false}.merge options + options = {weight: 0.1, threshold: 0.7, ignore_case: false, adj_table: false}.merge options weight, threshold, ignore_case = options[:weight], options[:threshold], options[:ignore_case] raise 'Scaling factor should not exceed 0.25, otherwise the distance can become larger than 1' if weight > 0.25 s1, s2 = s1.upcase, s2.upcase if ignore_case distance = jaro_distance(s1, s2, options) prefix = 0 \ No newline at end of file