mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
[ruby/did_you_mean] Remove Integer floor and prefix index from Jaro distance
The variable ``length2`` is an Integer, call to floor returns self. The variables ``i`` and ``prefix_bonus`` are equally incremented, no need to keep the ``i`` variable. https://github.com/ruby/did_you_mean/commit/4408802289
This commit is contained in:
parent
def7023ee4
commit
affbc79a10
@ -8,7 +8,7 @@ module DidYouMean
|
||||
|
||||
m = 0.0
|
||||
t = 0.0
|
||||
range = (length2 / 2).floor - 1
|
||||
range = length2 / 2 - 1
|
||||
range = 0 if range < 0
|
||||
flags1 = 0
|
||||
flags2 = 0
|
||||
@ -72,10 +72,8 @@ module DidYouMean
|
||||
codepoints2 = str2.codepoints
|
||||
prefix_bonus = 0
|
||||
|
||||
i = 0
|
||||
str1.each_codepoint do |char1|
|
||||
char1 == codepoints2[i] && i < 4 ? prefix_bonus += 1 : break
|
||||
i += 1
|
||||
char1 == codepoints2[prefix_bonus] && prefix_bonus < 4 ? prefix_bonus += 1 : break
|
||||
end
|
||||
|
||||
jaro_distance + (prefix_bonus * WEIGHT * (1 - jaro_distance))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user