vladlev 1.0.1 → 1.0.2

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: a3d833003de88f3525f4779667d4ecb83da15562
4
- data.tar.gz: 061e99aa0307164452a29d463f2ceddaf8610273
3
+ metadata.gz: d94c0b0374e6e487abacbf6879f4cf3a03df46ec
4
+ data.tar.gz: d83790f125d8a3bfaa437868a5ca434b003c5f7a
5
5
  SHA512:
6
- metadata.gz: b8622bb2248712886afcaf79fbf067deea3f01abc4f947f81c68c9d862a55ad1d22d8d3bfea1b9e5f3823e136cb2488bbf3fbd87bc185a8f9ef2fc61e72758ad
7
- data.tar.gz: 40fbc3bb0e328b9bfc6ddaeb247cb7ec0505aae90b995dc273f40358dfced4dcf4cbd3935e2d66265d56c1f1f4d07cb2451c8ecb1221a2859517266ed15866ba
6
+ metadata.gz: f9119f6d0d06fc3be7fe6efb3a498ea43892f6f693401ec2bb11557c95a210d685ac4cc9c04b4f97463ebbf6a73cf9cb24bcd9ab8b0e70d7fed4e29f937dcf1a
7
+ data.tar.gz: 73b6bfe192420b27424dfb5409321648b56d5626a308ba586ce40a0e3f66213f7add1d206793a674299ad34f115234e47eddd5465ff5ea1acc413d30a02860ed
@@ -52,15 +52,15 @@ public class LevenshteinDistance {
52
52
  return distance(str1, str2, 9999);
53
53
  }
54
54
 
55
- public static float normalized_distance(String str1, String str2) {
55
+ public static double normalized_distance(String str1, String str2) {
56
56
  return normalized_distance(str1, str2, 9999);
57
57
  }
58
58
 
59
- public static float normalized_distance(String str1, String str2, long maximumDistance) {
59
+ public static double normalized_distance(String str1, String str2, long maximumDistance) {
60
60
  int maxStringLength = (str1.length() > str2.length()) ? str1.length() : str2.length();
61
61
  if(maxStringLength == 0) {
62
62
  return 0;
63
63
  }
64
- return distance(str1, str2, maximumDistance) / (float)maxStringLength;
64
+ return distance(str1, str2, maximumDistance) / (double)maxStringLength;
65
65
  }
66
66
  }
@@ -105,7 +105,7 @@ int levenshtein_extern(char* a, char* b, int max_distance)
105
105
  return distance;
106
106
  }
107
107
 
108
- float normalized_levenshtein_extern(char* a, char* b, int max_distance)
108
+ double normalized_levenshtein_extern(char* a, char* b, int max_distance)
109
109
  {
110
110
  int a_len = (a == NULL) ? 0 : strlen(a);
111
111
  int b_len = (b == NULL) ? 0 : strlen(b);
@@ -114,5 +114,5 @@ float normalized_levenshtein_extern(char* a, char* b, int max_distance)
114
114
  if(max_string_length == 0) {
115
115
  return 0;
116
116
  }
117
- return (float)levenshtein_extern(a, b, max_distance) / max_string_length;
117
+ return levenshtein_extern(a, b, max_distance) / (double)max_string_length;
118
118
  }
Binary file
Binary file
@@ -36,7 +36,7 @@ module Vladlev
36
36
 
37
37
  ffi_lib native_file_path
38
38
  attach_function :levenshtein_extern, [:pointer, :pointer, :int32], :int32
39
- attach_function :normalized_levenshtein_extern, [:pointer, :pointer, :int32], :float
39
+ attach_function :normalized_levenshtein_extern, [:pointer, :pointer, :int32], :double
40
40
 
41
41
  # Calculate the levenshtein distance between two strings
42
42
  #
@@ -1,3 +1,3 @@
1
1
  module Vladlev
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -54,7 +54,7 @@ describe Vladlev do
54
54
  specify{ expect(Vladlev.get_normalized_distance("hi", "high", 1)).to eq(1.0) }
55
55
  specify{ expect(Vladlev.get_normalized_distance("hi", "high")).to eq(0.5) }
56
56
  specify{ expect(Vladlev.get_normalized_distance("hello", "hello")).to eq(0.0) }
57
- specify{ expect(Vladlev.get_normalized_distance("goodnight", "goodnite")).to eq(0.3333333432674408) }
57
+ specify{ expect(Vladlev.get_normalized_distance("goodnight", "goodnite")).to be_between(0.3333, 0.3334) }
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) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vladlev
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Stien