levenshtein 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +10 -0
- data/README +8 -8
- data/VERSION +1 -1
- data/lib/levenshtein.rb +2 -2
- data/test/test.rb +1 -0
- metadata +6 -4
data/CHANGELOG
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
0.1.1 (06-10-2008)
|
2
|
+
|
3
|
+
* If one of the strings was both the begin and the end of the
|
4
|
+
other string, it would be stripped from both ends. Example:
|
5
|
+
Levenshtein.distance("abracadabra", "abra") resulted in 3
|
6
|
+
instead of 7. It's fixed now.
|
7
|
+
|
8
|
+
0.1.0 (24-05-2008)
|
9
|
+
|
10
|
+
* First release.
|
data/README
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
The Levenshtein distance is a metric for measuring the amount of difference
|
2
|
+
between two sequences (i.e., the so called edit distance). The Levenshtein
|
3
|
+
distance between two strings is given by the minimum number of operations
|
4
|
+
needed to transform one string into the other, where an operation is an
|
5
|
+
insertion, deletion, or substitution of a single character.
|
6
|
+
|
7
|
+
More information about the Levenshtein distance algorithm:
|
8
|
+
http://en.wikipedia.org/wiki/Levenshtein_distance .
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/levenshtein.rb
CHANGED
@@ -18,7 +18,7 @@ end
|
|
18
18
|
# http://en.wikipedia.org/wiki/Levenshtein_distance .
|
19
19
|
|
20
20
|
module Levenshtein
|
21
|
-
# Returns the Levenshtein distance as a number
|
21
|
+
# Returns the Levenshtein distance as a number between 0.0 and 1.0.
|
22
22
|
# It's basically the Levenshtein distance divided by the length of the longest string.
|
23
23
|
|
24
24
|
def self.normalized_distance(s1, s2, threshold=nil)
|
@@ -62,7 +62,7 @@ module Levenshtein
|
|
62
62
|
b += 1
|
63
63
|
end
|
64
64
|
|
65
|
-
while s1[e1, 1] == s2[e2, 1]
|
65
|
+
while s1[e1, 1] == s2[e2, 1] and e1 > b and e2 > b
|
66
66
|
e1 -= 1
|
67
67
|
e2 -= 1
|
68
68
|
end
|
data/test/test.rb
CHANGED
@@ -40,6 +40,7 @@ class TestLevenshtein < Test::Unit::TestCase
|
|
40
40
|
assert_equal(3, Levenshtein.distance("ab123cd", "abxyzcd"))
|
41
41
|
assert_equal(3, Levenshtein.distance("ab123", "abxyz"))
|
42
42
|
assert_equal(3, Levenshtein.distance("123cd", "xyzcd"))
|
43
|
+
assert_equal(5, Levenshtein.distance("123cd123", "123"))
|
43
44
|
|
44
45
|
assert_in_delta(0.42, Levenshtein.normalized_distance("ab123cd", "abxyzcd"), 0.01)
|
45
46
|
assert_in_delta(0.6, Levenshtein.normalized_distance("ab123", "abxyz"), 0.01)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: levenshtein
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Veenstra
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-06 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -29,6 +29,7 @@ files:
|
|
29
29
|
- README
|
30
30
|
- LICENSE
|
31
31
|
- VERSION
|
32
|
+
- CHANGELOG
|
32
33
|
has_rdoc: true
|
33
34
|
homepage: http://www.erikveen.dds.nl/levenshtein/index.html
|
34
35
|
post_install_message:
|
@@ -36,8 +37,9 @@ rdoc_options:
|
|
36
37
|
- README
|
37
38
|
- LICENSE
|
38
39
|
- VERSION
|
40
|
+
- CHANGELOG
|
39
41
|
- --title
|
40
|
-
- levenshtein (0.1.
|
42
|
+
- levenshtein (0.1.1)
|
41
43
|
- --main
|
42
44
|
- README
|
43
45
|
require_paths:
|
@@ -57,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
59
|
requirements: []
|
58
60
|
|
59
61
|
rubyforge_project: levenshtein
|
60
|
-
rubygems_version: 1.0
|
62
|
+
rubygems_version: 1.2.0
|
61
63
|
signing_key:
|
62
64
|
specification_version: 2
|
63
65
|
summary: Calculates the Levenshtein distance between two byte strings.
|