Update find.jl
parent
388055a622
commit
8468d4fddc
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
findmax(s, itr [, dist::StringDistance = Levenshtein()]; min_score = 0.0) -> (x, index)
|
||||
findmax(s, itr, dist::StringDistance; min_score = 0.0) -> (x, index)
|
||||
|
||||
`findmax` returns the value and index of the element of `itr` that has the
|
||||
highest similarity score with `s` according to the distance `dist`.
|
||||
|
@ -20,7 +20,7 @@ julia> findmax(s, iter, Levenshtein(); min_score = 0.9)
|
|||
(nothing, nothing)
|
||||
```
|
||||
"""
|
||||
function Base.findmax(s, itr, dist::StringDistance = Levenshtein(); min_score = 0.0)
|
||||
function Base.findmax(s, itr, dist::StringDistance; min_score = 0.0)
|
||||
min_score_atomic = Threads.Atomic{typeof(min_score)}(min_score)
|
||||
scores = [0.0 for _ in 1:Threads.nthreads()]
|
||||
is = [0 for _ in 1:Threads.nthreads()]
|
||||
|
@ -38,7 +38,7 @@ function Base.findmax(s, itr, dist::StringDistance = Levenshtein(); min_score =
|
|||
end
|
||||
|
||||
"""
|
||||
findall(s, itr [, dist::StringDistance = Levenshtein()]; min_score = 0.8)
|
||||
findall(s, itr , dist::StringDistance; min_score = 0.8)
|
||||
|
||||
`findall` returns the vector of indices for elements of `itr` that have a
|
||||
similarity score higher or equal than `min_score` according to the distance `dist`.
|
||||
|
@ -59,7 +59,7 @@ julia> findall(s, iter, Levenshtein(); min_score = 0.9)
|
|||
0-element Array{Int64,1}
|
||||
```
|
||||
"""
|
||||
function Base.findall(s, itr, dist::StringDistance = Levenshtein; min_score = 0.8)
|
||||
function Base.findall(s, itr, dist::StringDistance; min_score = 0.8)
|
||||
out = [Int[] for _ in 1:Threads.nthreads()]
|
||||
# need collect since @threads requires a length method
|
||||
Threads.@threads for i in collect(eachindex(itr))
|
||||
|
|
Loading…
Reference in New Issue