class RuboCop::StringUtil::JaroWinkler

bonus to Jaro distance.
This class computes Jaro-Winkler distance, which adds prefix-matching

def common_prefix_length

def common_prefix_length
  shorter.size.times do |index|
    return index unless shorter[index] == longer[index]
  end
  shorter.size
end

def compute_distance

def compute_distance
  jaro_distance = super
  if jaro_distance >= boost_threshold
    bonus = limited_common_prefix_length.to_f * scaling_factor.to_f *
            (1.0 - jaro_distance)
    jaro_distance + bonus
  else
    jaro_distance
  end
end

def initialize(a, b, boost_threshold = nil, scaling_factor = nil)

def initialize(a, b, boost_threshold = nil, scaling_factor = nil)
  super(a, b)
  @boost_threshold = boost_threshold || DEFAULT_BOOST_THRESHOLD
  @scaling_factor = scaling_factor || DEFAULT_SCALING_FACTOR
end

def limited_common_prefix_length

def limited_common_prefix_length
  length = common_prefix_length
  if length > MAX_COMMON_PREFIX_LENGTH
    MAX_COMMON_PREFIX_LENGTH
  else
    length
  end
end