2015-10-22 18:12:44 +02:00
|
|
|
__precompile__(true)
|
|
|
|
|
|
|
|
module StringDistances
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
##
|
|
|
|
## Export
|
|
|
|
##
|
|
|
|
##############################################################################
|
|
|
|
|
2015-10-25 22:26:17 +01:00
|
|
|
import Distances: evaluate, Hamming, hamming, PreMetric, SemiMetric
|
2015-10-24 14:59:44 +02:00
|
|
|
export evaluate,
|
|
|
|
Hamming, hamming,
|
|
|
|
Levenshtein, levenshtein,
|
|
|
|
DamerauLevenshtein, damerau_levenshtein,
|
2015-10-25 16:23:46 +01:00
|
|
|
Jaro, jaro,
|
2015-10-24 14:59:44 +02:00
|
|
|
QGram, qgram,
|
|
|
|
Cosine, cosine,
|
2015-10-25 16:23:46 +01:00
|
|
|
Jaccard, jaccard,
|
|
|
|
Normalized,
|
|
|
|
Winkler
|
|
|
|
|
2015-10-25 16:39:33 +01:00
|
|
|
|
|
|
|
# 1. only do the switch once
|
|
|
|
# 2. precomputes length(s1), length(s2)
|
2015-11-02 18:52:23 +01:00
|
|
|
function evaluate(dist::PreMetric, s1::AbstractString, s2::AbstractString, x...)
|
2015-10-25 16:39:33 +01:00
|
|
|
len1, len2 = length(s1), length(s2)
|
|
|
|
if len1 > len2
|
2015-11-02 18:52:23 +01:00
|
|
|
return evaluate(dist, s2, s1, len2, len1, x...)
|
2015-10-25 16:39:33 +01:00
|
|
|
else
|
2015-11-02 18:52:23 +01:00
|
|
|
return evaluate(dist, s1, s2, len1, len2, x...)
|
2015-10-25 16:23:46 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
include("edit.jl")
|
|
|
|
include("qgram.jl")
|
|
|
|
include("normalized.jl")
|
|
|
|
include("winkler.jl")
|
2015-10-22 18:53:27 +02:00
|
|
|
|
2015-10-22 18:12:44 +02:00
|
|
|
|
2015-10-22 18:38:04 +02:00
|
|
|
end
|