class Cadmium::JaroWinklerDistance

Overview

Computes the Jaro distance between two string. Code credit goes to kostya. https://github.com/kostya/jaro_winkler

Defined in:

cadmium/distance/jaro_winkler.cr

Constant Summary

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

Instance Method Summary

Constructor Detail

def self.new(weight : Float64 = 0.1, threshold : Float64 = 0.7, ignore_case : Bool = false, adj_table : Bool = false) #

[View source]

Instance Method Detail

def distance(s1 : String, s2 : String) #

[View source]
def distance(codes1 : Array(Char), codes2 : Array(Char)) #

[View source]
def jaro_distance(s1 : String, s2 : String) #

[View source]
def jaro_distance(codes1 : Array(Char), codes2 : Array(Char)) #

[View source]
def match_count(len1, len2, flags1, flags2, codes1, codes2, window) #

[View source]