levenshtein-jruby 0.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/levenshtein-jruby.gemspec +25 -0
- data/lib/commons-lang3-3.1.jar +0 -0
- data/lib/levenshtein-jruby.rb +1 -0
- data/lib/levenshtein.rb +16 -0
- data/lib/levenshtein/version.rb +3 -0
- data/test/levenshtein_test.rb +13 -0
- data/test/test_helper.rb +3 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b45a6d20e9c199a82646fabec41cad107eb2f13f
|
4
|
+
data.tar.gz: 2277cd123051c8e96cacc52f16792169a4513a05
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 287e87f3e8749898f588eedcf2c98528c17feac354ee53bd18fc2ea7f998d96784f8ea3869c1a7e22bc5a6dc9fa68bb0272a8cbafe073668a638cbacef3bf3ac
|
7
|
+
data.tar.gz: a4886fa2941f16b669537529e0021561db5394e1695cf46c5618b9105de4dd7569db6701623b4ea46101c732979e0f13b0782bef6f616a23427567c9ebc36c05
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 David Butler
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Levenshtein (JRuby)
|
2
|
+
[![Build Status](https://travis-ci.org/dwbutler/levenshtein-jruby.png)](https://travis-ci.org/dwbutler/levenshtein-jruby)
|
3
|
+
|
4
|
+
Calculates the Levenshtein distance between two strings. Uses the
|
5
|
+
[Apache Commons](http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#getLevenshteinDistance\(java.lang.CharSequence, java.lang.CharSequence\)) Java implementation.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'levenshtein-jruby'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install levenshtein-jruby
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'levenshtein'
|
25
|
+
|
26
|
+
# Basic usage
|
27
|
+
Levenshtein.distance("string1", "string2") # => 1
|
28
|
+
|
29
|
+
# With threshold
|
30
|
+
Levenshtein.distance("string1", "String2", 2) # => 2
|
31
|
+
```
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'levenshtein/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "levenshtein-jruby"
|
8
|
+
spec.version = Levenshtein::VERSION
|
9
|
+
spec.platform = 'java'
|
10
|
+
|
11
|
+
spec.authors = ["David Butler"]
|
12
|
+
spec.email = ["dwbutler@ucla.edu"]
|
13
|
+
spec.description = %q{Calculate the Levenshtein distance between two strings in JRuby}
|
14
|
+
spec.summary = %q{Levenshtein gem that runs in JRuby}
|
15
|
+
spec.homepage = "https://github.com/dwbutler/levenshtein-jruby"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'levenshtein'
|
data/lib/levenshtein.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html
|
2
|
+
|
3
|
+
require 'commons-lang3-3.1'
|
4
|
+
|
5
|
+
module Levenshtein
|
6
|
+
java_import org.apache.commons.lang3.StringUtils
|
7
|
+
|
8
|
+
# Find the Levenshtein distance between two strings.
|
9
|
+
def self.distance(string1, string2, threshold=nil)
|
10
|
+
if threshold
|
11
|
+
StringUtils.get_levenshtein_distance(string1, string2, threshold)
|
12
|
+
else
|
13
|
+
StringUtils.get_levenshtein_distance(string1, string2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class LevenshteinTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_levenshtein
|
6
|
+
assert Levenshtein.distance("test", "Test") == 1
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_levenshtein_threshold
|
10
|
+
assert Levenshtein.distance("test 1", "Test 2", 1) == -1
|
11
|
+
assert Levenshtein.distance("test 1", "Test 2", 3) == 2
|
12
|
+
end
|
13
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: levenshtein-jruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- David Butler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '1.3'
|
25
|
+
prerelease: false
|
26
|
+
type: :development
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
prerelease: false
|
40
|
+
type: :development
|
41
|
+
description: Calculate the Levenshtein distance between two strings in JRuby
|
42
|
+
email:
|
43
|
+
- dwbutler@ucla.edu
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .travis.yml
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- levenshtein-jruby.gemspec
|
55
|
+
- lib/commons-lang3-3.1.jar
|
56
|
+
- lib/levenshtein-jruby.rb
|
57
|
+
- lib/levenshtein.rb
|
58
|
+
- lib/levenshtein/version.rb
|
59
|
+
- test/levenshtein_test.rb
|
60
|
+
- test/test_helper.rb
|
61
|
+
homepage: https://github.com/dwbutler/levenshtein-jruby
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.1.9
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Levenshtein gem that runs in JRuby
|
85
|
+
test_files:
|
86
|
+
- test/levenshtein_test.rb
|
87
|
+
- test/test_helper.rb
|