vladlev 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d94c0b0374e6e487abacbf6879f4cf3a03df46ec
4
- data.tar.gz: d83790f125d8a3bfaa437868a5ca434b003c5f7a
3
+ metadata.gz: 549364d4ff5f3575b4afa97099b2e15234e4e3b8
4
+ data.tar.gz: 070cdd8c92106cfeee35217539990885a43fceb1
5
5
  SHA512:
6
- metadata.gz: f9119f6d0d06fc3be7fe6efb3a498ea43892f6f693401ec2bb11557c95a210d685ac4cc9c04b4f97463ebbf6a73cf9cb24bcd9ab8b0e70d7fed4e29f937dcf1a
7
- data.tar.gz: 73b6bfe192420b27424dfb5409321648b56d5626a308ba586ce40a0e3f66213f7add1d206793a674299ad34f115234e47eddd5465ff5ea1acc413d30a02860ed
6
+ metadata.gz: aac342db31859dd14255adb783a724680e2bea0e15f9bc3ece53fd697200cbd86ad7b5cdc9bac5fceb2e4b75813427cdb2cf96fc2ffc678f773a470b0ee7df3f
7
+ data.tar.gz: 8c180e7d70d183ae0c1c2fb2466962c63745cd4d4c78eedbd54e03bc7c5e9a28ad854bc1063666961104331488679f3353baa0385b94edbd09d30d5c24518937
data/.gitignore CHANGED
@@ -6,3 +6,6 @@ Gemfile.lock
6
6
  coverage
7
7
  pkg/*
8
8
  tmp
9
+ .ruby-gemset
10
+ .ruby-version
11
+ ext/
Binary file
@@ -1,3 +1,3 @@
1
1
  module Vladlev
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
data/lib/vladlev.rb CHANGED
@@ -4,7 +4,7 @@ module Vladlev
4
4
  end
5
5
 
6
6
  JRUBY_NATIVE = RUBY_PLATFORM =~ /java/ && relative_exists?('levenshtein.jar')
7
- C_EXT_NATIVE = !JRUBY_NATIVE &&
7
+ C_EXT_NATIVE = !JRUBY_NATIVE &&
8
8
  (relative_exists?('levenshtein.bundle') || relative_exists?('levenshtein.so'))
9
9
 
10
10
  if JRUBY_NATIVE
@@ -54,7 +54,7 @@ module Vladlev
54
54
  require 'vladlev/levenshtein'
55
55
  warn <<-PURE_RUBY
56
56
  Could not load C extension or Java Extension for Vladlev
57
- Will utilize pure ruby version which is significantly
57
+ Will utilize pure ruby version which is significantly
58
58
  slower for many comparisons.
59
59
  PURE_RUBY
60
60
 
@@ -78,8 +78,8 @@ module Vladlev
78
78
 
79
79
  def self.get_normalized_distance(str1, str2, max = 9999)
80
80
  return 0 if str1.nil? && str2.nil?
81
- return str2.size if str1.nil?
82
- return str1.size if str2.nil?
81
+ return 1.0 if str1.nil?
82
+ return 1.0 if str2.nil?
83
83
 
84
84
  self._normalized_distance(str1, str2, max)
85
85
  end
@@ -14,36 +14,36 @@ describe Vladlev do
14
14
  specify{ Vladlev.distance("hello"*2, "jelo"*2).should equal(4) }
15
15
  specify{ Vladlev.distance("hello"*2, "jell"*2).should equal(4) }
16
16
  specify{ Vladlev.distance("hello"*4, "jello"*4).should equal(4) }
17
- specify{ Vladlev.distance("hello"*8, "jello"*8).should equal(8) }
17
+ specify{ Vladlev.distance("hello"*8, "jello"*8).should equal(8) }
18
18
  specify{ Vladlev.distance("hello"*16, "jello"*16).should equal(16) }
19
19
  specify{ Vladlev.distance("hello"*32, "jello"*32).should equal(32) }
20
20
  specify{ Vladlev.distance("hello"*64, "jello"*64).should equal(64) }
21
21
  specify{ Vladlev.distance("hello"*128, "jello"*128).should equal(128) }
22
22
  specify{ Vladlev.distance("hello"*256, "jello"*256).should equal(256) }
23
- specify{ Vladlev.distance("hello"*512, "jello"*512).should equal(512) }
24
-
25
- describe "threshold" do
23
+ specify{ Vladlev.distance("hello"*512, "jello"*512).should equal(512) }
24
+
25
+ describe "threshold" do
26
26
  specify{ Vladlev.distance("hello"*100, "jello"*100, 10).should equal(500) }
27
27
  specify{ Vladlev.distance("hello"*100, "jello"*100, 99).should equal(500) }
28
- specify{ Vladlev.distance("hello"*100, "jello"*100, 100).should equal(100) }
29
- specify{ Vladlev.distance("hello"*100, "jello"*100, 1000).should equal(100) }
28
+ specify{ Vladlev.distance("hello"*100, "jello"*100, 100).should equal(100) }
29
+ specify{ Vladlev.distance("hello"*100, "jello"*100, 1000).should equal(100) }
30
30
  end
31
31
 
32
- describe "long strings" do
32
+ describe "long strings" do
33
33
  specify{ Vladlev.distance("hello"*200, "jello"*200).should equal(200) }
34
34
  specify{ Vladlev.distance("hello"*500, "jello"*500).should equal(500) }
35
35
  specify{ Vladlev.distance("hello"*750, "jello"*750).should equal(750) }
36
- specify{ Vladlev.distance("hello"*950, "jello"*950).should equal(950) }
36
+ specify{ Vladlev.distance("hello"*950, "jello"*950).should equal(950) }
37
37
  end
38
38
 
39
- describe "threshold long strings" do
39
+ describe "threshold long strings" do
40
40
  specify{ Vladlev.distance("hello"*2000, "jello"*2000, 10).should equal(5*2000) }
41
41
  specify{ Vladlev.distance("hello"*5000, "jello"*5000, 10).should equal(5*5000) }
42
42
  specify{ Vladlev.distance("hello"*7500, "jello"*7500, 10).should equal(5*7500) }
43
- specify{ Vladlev.distance("hello"*9500, "jello"*9500, 10).should equal(5*9500) }
43
+ specify{ Vladlev.distance("hello"*9500, "jello"*9500, 10).should equal(5*9500) }
44
44
  end
45
45
 
46
- describe "special chars" do
46
+ describe "special chars" do
47
47
  specify{ Vladlev.distance("*&^%$", "").should equal(5) }
48
48
  specify{ Vladlev.distance("", ",./>?").should equal(5) }
49
49
  specify{ Vladlev.distance('*&^%$+_=-)(*&^%$#@!~123456789', '*&^%$+_=-)(*&^%$#@!~').should equal(9) }
@@ -58,8 +58,11 @@ describe Vladlev do
58
58
  specify{ expect(Vladlev.get_normalized_distance("", "goodbye")).to eq(1.0) }
59
59
  specify{ expect(Vladlev.get_normalized_distance("goodbye", "")).to eq(1.0) }
60
60
  specify{ expect(Vladlev.get_normalized_distance("", "")).to eq(0.0) }
61
+ specify{ expect(Vladlev.get_normalized_distance(nil, nil)).to eq(0.0) }
62
+ specify{ expect(Vladlev.get_normalized_distance("hi", nil)).to eq(1.0) }
63
+ specify{ expect(Vladlev.get_normalized_distance(nil, "goodbye")).to eq(1.0) }
61
64
  end
62
-
65
+
63
66
  describe '#distance' do
64
67
  context "when given two strings to match" do
65
68
  it "returns the distance" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vladlev
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Stien
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2015-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi