Module: StrMetrics::JaroWinkler

Defined in:
lib/str_metrics.rb

Overview

Namespace for Jaro-Winkler

Class Method Summary collapse

Class Method Details

.distance(a, b, ignore_case: false, prefix_scaling_factor: 0.1, prefix_scaling_bonus_threshold: 0.7) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/str_metrics.rb', line 80

def self.distance(
  a,
  b,
  ignore_case: false,
  prefix_scaling_factor: 0.1,
  prefix_scaling_bonus_threshold: 0.7
)
  Native.jaro_winkler_distance(
    a&.to_utf8,
    b&.to_utf8,
    ignore_case ? 1 : 0,
    4,
    prefix_scaling_factor,
    prefix_scaling_bonus_threshold
  )
end

.similarity(a, b, ignore_case: false, prefix_scaling_factor: 0.1, prefix_scaling_bonus_threshold: 0.7) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/str_metrics.rb', line 63

def self.similarity(
  a,
  b,
  ignore_case: false,
  prefix_scaling_factor: 0.1,
  prefix_scaling_bonus_threshold: 0.7
)
  Native.jaro_winkler_similarity(
    a&.to_utf8,
    b&.to_utf8,
    ignore_case ? 1 : 0,
    4,
    prefix_scaling_factor,
    prefix_scaling_bonus_threshold
  )
end