Skip to content

Commit

Permalink
Merge pull request #10 from rened/deprfix
Browse files Browse the repository at this point in the history
fixes deprecation warnings for 0.4
  • Loading branch information
rawrgrr committed Oct 13, 2015
2 parents 33d41ff + 6e5fd7d commit 71dc276
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ os:
- linux
- osx
julia:
- release
- 0.3
- 0.4
- nightly
notifications:
email: false
Expand Down
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
julia 0.3
Compat
12 changes: 7 additions & 5 deletions src/Levenshtein.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@
##
module Levenshtein

using Compat

export levenshtein
export levenshtein!


function levenshtein(source::String, target::String)
function levenshtein(source::AbstractString, target::AbstractString)
return levenshtein(source, target, 1)
end

function levenshtein(source::String, target::String, cost::Real)
function levenshtein(source::AbstractString, target::AbstractString, cost::Real)
return levenshtein(source, target, cost, cost, cost)
end

function levenshtein{R<:Real,S<:Real,T<:Real}(source::String, target::String, deletion_cost::R, insertion_cost::S, substitution_cost::T)
function levenshtein{R<:Real,S<:Real,T<:Real}(source::AbstractString, target::AbstractString, deletion_cost::R, insertion_cost::S, substitution_cost::T)
return levenshtein!(target, source, insertion_cost, deletion_cost, substitution_cost)
end

function levenshtein!{R<:Real,S<:Real,T<:Real}(
source::String,
target::String,
source::AbstractString,
target::AbstractString,
deletion_cost::R,
insertion_cost::S,
substitution_cost::T,
Expand Down
2 changes: 1 addition & 1 deletion test/performance.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Levenshtein

function randString(len)
return utf8(string([char(int(rand() * 255 + 1)) for _ in 1:len]...))
return utf8(string([Char(round(Int,rand() * 255 + 1)) for _ in 1:len]...))
end

function run_huge_string(l1, l2)
Expand Down
11 changes: 4 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using Levenshtein
using Base.Test
using Compat

function levenshtein_base(a::String, b::String, deletion_cost::Real, insertion_cost::Real, substitution_cost::Real)
function levenshtein_base(a::AbstractString, b::AbstractString, deletion_cost::Real, insertion_cost::Real, substitution_cost::Real)
local costs::Array{Real, 2} = zeros(Real, length(a) + 1, length(b) + 1)
# Initialize the deletion costs
for i in 1:length(a)
Expand Down Expand Up @@ -59,13 +60,9 @@ end
@test levenshtein("a", "", 10, 0, 0) == 10
@test levenshtein("", "a", 0, 10, 0) == 10

function randString(len)
return utf8(string([char(int(rand() * 255 + 1)) for _ in 1:len]...))
end

for i in 1:100
s = randString(floor(rand() * 100))
t = randString(floor(rand() * 100))
s = randstring(floor(Int,rand() * 100))
t = randstring(floor(Int,rand() * 100))
ins, del, sub = rand() * 1000, rand() * 1000, rand() * 1000

calculated, truth = levenshtein(s, t, del, ins, sub), levenshtein_base(s, t, del, ins, sub)
Expand Down

0 comments on commit 71dc276

Please sign in to comment.