module RecordLinkage::ObjectComparer::Matcher::Matchers
A module to hold the various matcher logic which can be declared with a String or a Symbol
Constants
- JAROW
Public Class Methods
array_exact_string_matcher(array1, array2, options = {})
click to toggle source
# File lib/record_linkage/object_comparer.rb, line 34 def self.array_exact_string_matcher(array1, array2, options = {}) array_matcher(:exact_string_matcher, array1, array2, options) end
array_fuzzy_string_matcher(array1, array2, options = {})
click to toggle source
# File lib/record_linkage/object_comparer.rb, line 30 def self.array_fuzzy_string_matcher(array1, array2, options = {}) array_matcher(:fuzzy_string_matcher, array1, array2, options) end
array_matcher(single_matcher, array1, array2, options = {})
click to toggle source
# File lib/record_linkage/object_comparer.rb, line 38 def self.array_matcher(single_matcher, array1, array2, options = {}) array1.map do |value1| array2.map do |value2| send(single_matcher, value1, value2, options) end end.flatten.sum end
exact_string_matcher(value1, value2, _options = {})
click to toggle source
# File lib/record_linkage/object_comparer.rb, line 24 def self.exact_string_matcher(value1, value2, _options = {}) value1 = value1.to_s.strip.downcase value2 = value2.to_s.strip.downcase (value1.size >= 1 && value1 == value2) ? 1.0 : 0.0 end
fuzzy_string_matcher(value1, value2, options = {})
click to toggle source
# File lib/record_linkage/object_comparer.rb, line 15 def self.fuzzy_string_matcher(value1, value2, options = {}) if value1.to_s.strip.size < 3 || value2.to_s.strip.size < 3 0.0 else score = JAROW.getDistance(value1.downcase, value2.downcase) score > options[:threshold] ? score : 0 end end