indentations

pull/1/head
matthieugomez 2015-10-25 11:39:33 -04:00
parent 40e22a5605
commit 3cf5dcef34
2 changed files with 8 additions and 14 deletions

View File

@ -20,20 +20,18 @@ Jaccard, jaccard,
Normalized, Normalized,
Winkler Winkler
# Two reasons for this method
# 1. only do the switch once (becomes more complicated when calling Normalized or Winkler Adjusted distance # 1. only do the switch once
# 2. precomputes length(s1), length(s2) since costly for Unicode (I think it needs to traverse the array?) # 2. precomputes length(s1), length(s2)
function evaluate(dist, s1::AbstractString, s2::AbstractString) function evaluate(dist, s1::AbstractString, s2::AbstractString)
len1, len2 = length(s1), length(s2) len1, len2 = length(s1), length(s2)
if len1 > len2 if len1 > len2
return evaluate(dist, s2, s1, len2, len1) return evaluate(dist, s2, s1, len2, len1)
else else
return evaluate(dist, s1, s2, len1, len2) return evaluate(dist, s1, s2, len1, len2)
end end
end end
include("edit.jl") include("edit.jl")
include("qgram.jl") include("qgram.jl")
include("normalized.jl") include("normalized.jl")

View File

@ -18,8 +18,6 @@ function common_prefix(s1::AbstractString, s2::AbstractString, lim::Integer = -1
return l, start1, start2 return l, start1, start2
end end
############################################################################## ##############################################################################
## ##
## Hamming ## Hamming
@ -27,7 +25,6 @@ end
############################################################################## ##############################################################################
function evaluate(dist::Hamming, s1::AbstractString, s2::AbstractString, len1::Integer, len2::Integer) function evaluate(dist::Hamming, s1::AbstractString, s2::AbstractString, len1::Integer, len2::Integer)
count = 0 count = 0
state2 = start(s2) state2 = start(s2)
for ch1 in s1 for ch1 in s1
@ -203,7 +200,6 @@ function evaluate(dist::Jaro, s1::AbstractString, s2::AbstractString, len1::Inte
end end
m == 0.0 && return 1.0 m == 0.0 && return 1.0
score = (m / len1 + m / len2 + (m - t) / m) / 3.0 score = (m / len1 + m / len2 + (m - t) / m) / 3.0
return 1 - score return 1 - score
end end