dynarex-levenshtein 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dynarexlevenshtein.rb +3 -2
- metadata +1 -1
data/lib/dynarexlevenshtein.rb
CHANGED
@@ -17,8 +17,8 @@ class DynarexLevenshtein
|
|
17
17
|
a, b = [a, b].sort_by(&:length)
|
18
18
|
n, m = a.length, b.length
|
19
19
|
|
20
|
-
schema = 'table[title,string1,string2]/rows(' +
|
21
|
-
|
20
|
+
schema = 'table[title,string1,string2, distance]/rows(' + \
|
21
|
+
(['line','label'] + (1..n).map{|x| "col%s" % x}).join(',') + ')'
|
22
22
|
@to_dynarex = Dynarex.new(schema)
|
23
23
|
|
24
24
|
@to_dynarex.summary[:title] = 'Calculates the Levenshtein distance between a and b.'
|
@@ -50,6 +50,7 @@ class DynarexLevenshtein
|
|
50
50
|
h = Hash[([:line, :label] + (0..n).map{|x| ("col%s" % x).to_sym}).zip([(m+1).to_s, label[-1]] + current)]
|
51
51
|
@to_dynarex.create h
|
52
52
|
|
53
|
+
@to_dynarex.summary[:distance] = current[n]
|
53
54
|
current[n]
|
54
55
|
end
|
55
56
|
end
|