levenshtein-ffi 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +19 -0
- data/README.markdown +4 -0
- data/README.markdown.html +70 -0
- data/VERSION +1 -1
- data/levenshtein-ffi.gemspec +24 -25
- data/lib/levenshtein-ffi.rb +1 -0
- data/spec/levenshtein_spec.rb +13 -15
- metadata +66 -75
- data/.gitignore +0 -4
data/Gemfile.lock
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ffi (1.0.9)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.6.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rake (0.9.2)
|
11
|
+
rspec (1.3.1)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
ffi
|
18
|
+
jeweler
|
19
|
+
rspec (= 1.3.1)
|
data/README.markdown
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
<h1>levenshtein-ffi</h1>
|
2
|
+
|
3
|
+
<p>Converted to FFI by David Balatero for Ruby portability.</p>
|
4
|
+
|
5
|
+
<p>This gem originally based on levenshtein.</p>
|
6
|
+
|
7
|
+
<p>Tested on:</p>
|
8
|
+
|
9
|
+
<ul>
|
10
|
+
<li>MRI 1.8.6</li>
|
11
|
+
<li>MRI 1.8.7</li>
|
12
|
+
<li>MRI 1.9.1</li>
|
13
|
+
<li>MRI 1.9.2</li>
|
14
|
+
<li>Rubinius 1.1.0</li>
|
15
|
+
</ul>
|
16
|
+
|
17
|
+
<h1>Known Issues</h1>
|
18
|
+
|
19
|
+
<ul>
|
20
|
+
<li>The C extension uses <code>char*</code> strings, and so Unicode characters will give incorrect values.</li>
|
21
|
+
</ul>
|
22
|
+
|
23
|
+
<h1>Including in Gemfile</h1>
|
24
|
+
|
25
|
+
<pre><code>gem 'levenshtein-ffi', :require => 'levenshtein'
|
26
|
+
</code></pre>
|
27
|
+
|
28
|
+
<h1>Original README</h1>
|
29
|
+
|
30
|
+
<p>The levenshtein module implements fast Damerau-Levenshtein edit distance
|
31
|
+
computation in O(n) memory and O(n^2) time, using a C wrapper. The module has a
|
32
|
+
single function:</p>
|
33
|
+
|
34
|
+
<pre><code>require 'levenshtein'
|
35
|
+
Levenshtein.distance("string1", "string2") == 1 # returns true
|
36
|
+
</code></pre>
|
37
|
+
|
38
|
+
<p>This function can be used as a drop-in replacement for
|
39
|
+
Text::Levenshtein.levenshtein, which is pure Ruby and rather slow. That’s it!</p>
|
40
|
+
|
41
|
+
<p>The code is made available under the following BSD license:</p>
|
42
|
+
|
43
|
+
<p>Copyright (c) 2009, Schuyler Erle.
|
44
|
+
All rights reserved.</p>
|
45
|
+
|
46
|
+
<p>Redistribution and use in source and binary forms, with or without
|
47
|
+
modification, are permitted provided that the following conditions are met:</p>
|
48
|
+
|
49
|
+
<pre><code>* Redistributions of source code must retain the above copyright notice,
|
50
|
+
this list of conditions and the following disclaimer.
|
51
|
+
|
52
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
53
|
+
this list of conditions and the following disclaimer in the documentation
|
54
|
+
and/or other materials provided with the distribution.
|
55
|
+
</code></pre>
|
56
|
+
|
57
|
+
<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
|
58
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
59
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
60
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
61
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
62
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
63
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
64
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
65
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
66
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
|
67
|
+
|
68
|
+
<ul>
|
69
|
+
<li>end -</li>
|
70
|
+
</ul>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/levenshtein-ffi.gemspec
CHANGED
@@ -1,61 +1,60 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{levenshtein-ffi}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David Balatero"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-09-05}
|
13
13
|
s.description = %q{Provides a fast, cross-Ruby implementation of the levenshtein distance algorithm.}
|
14
14
|
s.email = %q{dbalatero@gmail.com}
|
15
15
|
s.extensions = ["ext/levenshtein/extconf.rb"]
|
16
16
|
s.extra_rdoc_files = [
|
17
|
-
"README.markdown"
|
17
|
+
"README.markdown",
|
18
|
+
"README.markdown.html"
|
18
19
|
]
|
19
20
|
s.files = [
|
20
|
-
".
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
"CHANGELOG.markdown",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"README.markdown",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"ext/levenshtein/.gitignore",
|
28
|
+
"ext/levenshtein/extconf.rb",
|
29
|
+
"ext/levenshtein/levenshtein.c",
|
30
|
+
"ext/levenshtein/levenshtein.h",
|
31
|
+
"levenshtein-ffi.gemspec",
|
32
|
+
"lib/levenshtein-ffi.rb",
|
33
|
+
"lib/levenshtein.rb",
|
34
|
+
"spec/levenshtein_spec.rb",
|
35
|
+
"spec/spec_helper.rb"
|
34
36
|
]
|
35
37
|
s.homepage = %q{http://github.com/dbalatero/levenshtein-ffi}
|
36
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
37
38
|
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = %q{1.
|
39
|
+
s.rubygems_version = %q{1.6.2}
|
39
40
|
s.summary = %q{An FFI version of the levenshtein gem.}
|
40
|
-
s.test_files = [
|
41
|
-
"spec/levenshtein_spec.rb",
|
42
|
-
"spec/spec_helper.rb"
|
43
|
-
]
|
44
41
|
|
45
42
|
if s.respond_to? :specification_version then
|
46
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
43
|
s.specification_version = 3
|
48
44
|
|
49
45
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<ffi>, [">= 0"])
|
50
47
|
s.add_runtime_dependency(%q<ffi>, [">= 0"])
|
51
48
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
52
49
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
53
50
|
else
|
51
|
+
s.add_dependency(%q<ffi>, [">= 0"])
|
54
52
|
s.add_dependency(%q<ffi>, [">= 0"])
|
55
53
|
s.add_dependency(%q<rspec>, [">= 0"])
|
56
54
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
57
55
|
end
|
58
56
|
else
|
57
|
+
s.add_dependency(%q<ffi>, [">= 0"])
|
59
58
|
s.add_dependency(%q<ffi>, [">= 0"])
|
60
59
|
s.add_dependency(%q<rspec>, [">= 0"])
|
61
60
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'levenshtein'
|
data/spec/levenshtein_spec.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Levenshtein do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
]
|
16
|
-
end
|
4
|
+
fixtures = [
|
5
|
+
["hello", "hello", 0],
|
6
|
+
["hello", "helo", 1],
|
7
|
+
["hello", "jello", 1],
|
8
|
+
["hello", "helol", 1],
|
9
|
+
["hello", "hellol", 1],
|
10
|
+
["hello", "heloll", 2],
|
11
|
+
["hello", "cheese", 4],
|
12
|
+
["hello", "saint", 5],
|
13
|
+
["hello", "", 5],
|
14
|
+
]
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
fixtures.each do |w1, w2, d|
|
17
|
+
it "should calculate a distance of #{d} between #{w1} and #{w2}" do
|
20
18
|
Levenshtein.distance(w1, w2).should == d
|
21
19
|
Levenshtein.distance(w2, w1).should == d
|
22
20
|
end
|
metadata
CHANGED
@@ -1,77 +1,74 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: levenshtein-ffi
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- David Balatero
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2010-11-04 00:00:00 -07:00
|
12
|
+
date: 2011-09-05 00:00:00.000000000 -07:00
|
19
13
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: ffi
|
17
|
+
requirement: &2164470340 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
|
25
|
+
version_requirements: *2164470340
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: ffi
|
28
|
+
requirement: &2164472060 !ruby/object:Gem::Requirement
|
25
29
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
33
34
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rspec
|
37
35
|
prerelease: false
|
38
|
-
|
36
|
+
version_requirements: *2164472060
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
requirement: &2164550620 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
version: "0"
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
47
45
|
type: :development
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: jeweler
|
51
46
|
prerelease: false
|
52
|
-
|
47
|
+
version_requirements: *2164550620
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: jeweler
|
50
|
+
requirement: &2164718380 !ruby/object:Gem::Requirement
|
53
51
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
version: "0"
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
61
56
|
type: :development
|
62
|
-
|
63
|
-
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *2164718380
|
59
|
+
description: Provides a fast, cross-Ruby implementation of the levenshtein distance
|
60
|
+
algorithm.
|
64
61
|
email: dbalatero@gmail.com
|
65
62
|
executables: []
|
66
|
-
|
67
|
-
extensions:
|
63
|
+
extensions:
|
68
64
|
- ext/levenshtein/extconf.rb
|
69
|
-
extra_rdoc_files:
|
65
|
+
extra_rdoc_files:
|
70
66
|
- README.markdown
|
71
|
-
|
72
|
-
|
67
|
+
- README.markdown.html
|
68
|
+
files:
|
73
69
|
- CHANGELOG.markdown
|
74
70
|
- Gemfile
|
71
|
+
- Gemfile.lock
|
75
72
|
- README.markdown
|
76
73
|
- Rakefile
|
77
74
|
- VERSION
|
@@ -80,43 +77,37 @@ files:
|
|
80
77
|
- ext/levenshtein/levenshtein.c
|
81
78
|
- ext/levenshtein/levenshtein.h
|
82
79
|
- levenshtein-ffi.gemspec
|
80
|
+
- lib/levenshtein-ffi.rb
|
83
81
|
- lib/levenshtein.rb
|
84
82
|
- spec/levenshtein_spec.rb
|
85
83
|
- spec/spec_helper.rb
|
84
|
+
- README.markdown.html
|
86
85
|
has_rdoc: true
|
87
86
|
homepage: http://github.com/dbalatero/levenshtein-ffi
|
88
87
|
licenses: []
|
89
|
-
|
90
88
|
post_install_message:
|
91
|
-
rdoc_options:
|
92
|
-
|
93
|
-
require_paths:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
94
91
|
- lib
|
95
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
93
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
|
101
|
-
segments:
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
segments:
|
102
99
|
- 0
|
103
|
-
|
104
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
hash: -3210361372130881473
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
102
|
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
110
|
-
segments:
|
111
|
-
- 0
|
112
|
-
version: "0"
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
113
107
|
requirements: []
|
114
|
-
|
115
108
|
rubyforge_project:
|
116
|
-
rubygems_version: 1.
|
109
|
+
rubygems_version: 1.6.2
|
117
110
|
signing_key:
|
118
111
|
specification_version: 3
|
119
112
|
summary: An FFI version of the levenshtein gem.
|
120
|
-
test_files:
|
121
|
-
- spec/levenshtein_spec.rb
|
122
|
-
- spec/spec_helper.rb
|
113
|
+
test_files: []
|
data/.gitignore
DELETED