diff --git a/Project.toml b/Project.toml index 61cc014..cffa079 100644 --- a/Project.toml +++ b/Project.toml @@ -4,10 +4,12 @@ version = "0.10.0" [deps] Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" +StatsAPI = "82ae8749-77ed-4fe6-ae5f-f523153014b0" [compat] Distances = "0.8.1, 0.9, 0.10" julia = "1.3" +StatsAPI = "1" [extras] Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/src/StringDistances.jl b/src/StringDistances.jl index f146a97..2d83595 100755 --- a/src/StringDistances.jl +++ b/src/StringDistances.jl @@ -1,6 +1,7 @@ module StringDistances using Distances +import StatsAPI: pairwise, pairwise! include("distances/utils.jl") include("distances/edit.jl") diff --git a/src/pairwise.jl b/src/pairwise.jl index ad677b1..adadaa5 100644 --- a/src/pairwise.jl +++ b/src/pairwise.jl @@ -25,9 +25,7 @@ julia> pairwise(Levenshtein(), iter, iter2) 10.0 ``` """ -Distances.pairwise - -function Distances.pairwise(dist::StringDistance, xs::AbstractVector, ys::AbstractVector = xs; preprocess = nothing) +function pairwise(dist::StringDistance, xs::AbstractVector, ys::AbstractVector = xs; preprocess = nothing) T = result_type(dist, eltype(xs), eltype(ys)) if Missing <: Union{eltype(xs), eltype(ys)} T = Union{T, Missing} @@ -46,9 +44,7 @@ For AbstractQGramDistances preprocessing will be used either if `preprocess` is to true or if there are more than 5 elements in `xs`. Set `preprocess` to false if no preprocessing should be used, regardless of length. """ -Distances.pairwise! - -function Distances.pairwise!(R::AbstractMatrix, dist::StringDistance, xs::AbstractVector, ys::AbstractVector = xs; preprocess = nothing) +function pairwise!(R::AbstractMatrix, dist::StringDistance, xs::AbstractVector, ys::AbstractVector = xs; preprocess = nothing) length(xs) == size(R, 1) || throw(DimensionMismatch("inconsistent length")) length(ys) == size(R, 2) || throw(DimensionMismatch("inconsistent length")) ((xs === ys) & (dist isa SemiMetric)) ?