compathelper/new_version/2020-05-20-12-03-08-092-188304956
matthieugomez 2020-02-18 08:38:20 -05:00
parent 49b1f3b439
commit 26dd1c7427
2 changed files with 2 additions and 4 deletions

View File

@ -78,7 +78,7 @@ function (dist::Levenshtein)(s1, s2, max_dist = nothing)
max_dist !== nothing && len2 - len1 > max_dist && return max_dist + 1
# prefix common to both strings can be ignored
k = common_prefix(s1, s2)
(k == length(s1)) && return len2 - k
k == len1 && return len2 - k
# distance initialized to first row of matrix
# => distance between "" and s2[1:i}
v = collect(1:(len2-k))
@ -131,7 +131,7 @@ function (dist::DamerauLevenshtein)(s1, s2, max_dist = nothing)
max_dist !== nothing && len2 - len1 > max_dist && return max_dist + 1
# prefix common to both strings can be ignored
k = common_prefix(s1, s2)
(k == length(s1)) && return len2 - k
k == len1 && return len2 - k
v = collect(1:(len2-k))
w = similar(v)
if max_dist !== nothing

View File

@ -51,8 +51,6 @@ function common_prefix(s1, s2)
return l
end
function _take(s, n::Integer)
Base.Iterators.take(s, n)
end