Cadmium::JaroWinklerDistance
Inherits Reference / Object
Computes the Jaro distance between two string. Code credit goes to kostya. https://github.com/kostya/jaro_winkler
Constants
DEFAULT_ADJ_TABLE = [['A', 'E'], ['A', 'I'], ['A', 'O'], ['A', 'U'], ['B', 'V'], ['E', 'I'], ['E', 'O'], ['E', 'U'], ['I', 'O'], ['I', 'U'], ['O', 'U'], ['I', 'Y'], ['E', 'Y'], ['C', 'G'], ['E', 'F'], ['W', 'U'], ['W', 'V'], ['X', 'K'], ['S', 'Z'], ['X', 'S'], ['Q', 'C'], ['U', 'V'], ['M', 'N'], ['L', 'I'], ['Q', 'O'], ['P', 'R'], ['I', 'J'], ['2', 'Z'], ['5', 'S'], ['8', 'B'], ['1', 'I'], ['1', 'L'], ['0', 'O'], ['0', 'Q'], ['C', 'K'], ['G', 'J'], ['E', ' '], ['Y', ' '], ['S', ' ']].reduce(Set(Tuple(Char, Char)).new) do |set, elem|
c1, c2 = elem
set << {c1, c2}
set << {c2, c1}
set << {c1.downcase, c2.downcase}
set << {c2.downcase, c1.downcase}
set << {c1.downcase, c2}
set << {c2, c1.downcase}
set << {c1, c2.downcase}
set << {c2.downcase, c1}
set
end
Constructors
new(weight : Float64 = 0.1, threshold : Float64 = 0.7, ignore_case : Bool = false, adj_table : Bool = false)
SourceInstance methods
distance(s1 : String, s2 : String)
Sourcedistance(codes1 : Array(Char), codes2 : Array(Char))
Sourcejaro_distance(s1 : String, s2 : String)
Sourcejaro_distance(codes1 : Array(Char), codes2 : Array(Char))
Sourcematch_count(len1, len2, flags1, flags2, codes1, codes2, window)
Source