compathelper/new_version/2020-05-20-12-03-08-092-188304956
matthieugomez 2020-02-13 09:48:35 -05:00
parent 093c536377
commit f144292b70
4 changed files with 12 additions and 17 deletions

View File

@ -5,13 +5,24 @@ using Distances
include("utils.jl")
include("edit.jl")
include("qgram.jl")
include("modifiers.jl")
include("normalize.jl")
const StringDistance = Union{Jaro, Levenshtein, DamerauLevenshtein, RatcliffObershelp, QGramDistance, Winkler, Partial, TokenSort, TokenSet, TokenMax, Normalize}
Distances.result_type(dist::StringDistance, s1, s2) = typeof(dist("", ""))
"""
compare(s1, s2, dist)
return a similarity score between 0 and 1 for the strings `s1` and
`s2` based on the distance `dist`.
### Examples
```julia-repl
julia> compare("martha", "marhta", Levenshtein())
0.6666666666666667
```
"""
compare(s1, s2, dist::StringDistance; min_score = 0.0) = 1 - normalize(dist)(s1, s2, 1 - min_score)
include("find.jl")

View File

@ -24,7 +24,6 @@ function (dist::Jaro)(s1, s2)
len2 == 0 && return 0.0
maxdist = max(0, div(len2, 2) - 1)
flag = fill(false, len2)
prevstate1 = firstindex(s1)
ch1_match = Vector{eltype(s1)}(undef, len1)
# m counts number matching characters
m = 0

View File

@ -1,18 +1,3 @@
"""
compare(s1, s2, dist)
return a similarity score between 0 and 1 for the strings `s1` and
`s2` based on the distance `dist`.
### Examples
```julia-repl
julia> compare("martha", "marhta", Levenshtein())
0.6666666666666667
```
"""
compare(s1, s2, dist::StringDistance; min_score = 0.0) = 1 - normalize(dist)(s1, s2, 1 - min_score)
"""
findmax(s, itr, dist::StringDistance; min_score = 0.0) -> (x, index)