Module: Philiprehberger::FuzzyMatch::JaroWinkler
- Defined in:
- lib/philiprehberger/fuzzy_match/jaro_winkler.rb
Constant Summary collapse
- WINKLER_PREFIX_WEIGHT =
0.1- MAX_PREFIX_LENGTH =
4
Class Method Summary collapse
Class Method Details
.similarity(str_a, str_b) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/philiprehberger/fuzzy_match/jaro_winkler.rb', line 9 def self.similarity(str_a, str_b) a = str_a.to_s.downcase b = str_b.to_s.downcase return 1.0 if a == b return 0.0 if a.empty? || b.empty? jaro = jaro_similarity(a, b) prefix_len = common_prefix_length(a, b) jaro + (prefix_len * WINKLER_PREFIX_WEIGHT * (1.0 - jaro)) end |