slide_rule 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/lib/slide_rule/distance_calculators/levenshtein.rb +1 -2
- data/lib/slide_rule/version.rb +1 -1
- data/lib/slide_rule.rb +1 -1
- data/slide_rule.gemspec +1 -1
- data/spec/slide_rule/distance_calculator_spec.rb +1 -1
- data/spec/slide_rule/distance_calculators/levenshtein_spec.rb +1 -1
- metadata +35 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b3179055340569d383b2cc674b77271a8196ccd
|
4
|
+
data.tar.gz: 2bb292fb77379d76447ecd1aa623845cbeb7de64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5adc84a61af1e49a0e7e673b6b88115d389f3fc20e91e9fc568e10c8f6869bf8634ee80d7757f8e5d7eb484d530f4ef58154d6fb24712a6282c697cc86bef341
|
7
|
+
data.tar.gz: 53e0320c267447b19e756763415dc74756dc7958756bdc639e92d8848b90da848638cad6cf03f25070be0202b7bbd5a17dc650ec951bb40a000443f3f7be7073
|
data/.travis.yml
CHANGED
@@ -2,14 +2,13 @@ module SlideRule
|
|
2
2
|
module DistanceCalculators
|
3
3
|
class Levenshtein
|
4
4
|
def calculate(first, second)
|
5
|
-
|
5
|
+
::Vladlev.get_normalized_distance(first, second).to_f
|
6
6
|
|
7
7
|
# Lower bound is difference in length
|
8
8
|
# distance = matrix.last.last.to_f - (first.length - second.length).abs
|
9
9
|
|
10
10
|
# Upper bound is length of longest string
|
11
11
|
# This will decrease distance more for longer strings.
|
12
|
-
distance / ([first.length, second.length].max)
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
data/lib/slide_rule/version.rb
CHANGED
data/lib/slide_rule.rb
CHANGED
data/slide_rule.gemspec
CHANGED
@@ -94,7 +94,7 @@ describe ::SlideRule::DistanceCalculator do
|
|
94
94
|
# -----------------------------------------
|
95
95
|
# = 0.2318181818181818
|
96
96
|
distance = calculator.calculate_distance(example, candidate)
|
97
|
-
expect(distance).to eq((3.0 * 0.5 / 15) + (4.0 * 0.5 / 11))
|
97
|
+
expect(distance.round(4)).to eq(((3.0 * 0.5 / 15) + (4.0 * 0.5 / 11)).round(4))
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -6,6 +6,6 @@ describe ::SlideRule::DistanceCalculators::Levenshtein do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'should calculate distance as distance divided by length of longest string' do
|
9
|
-
expect(described_class.new.calculate('this is a test', 'this is a test!')).to eq(1.0 / 15)
|
9
|
+
expect(described_class.new.calculate('this is a test', 'this is a test!').round(4)).to eq((1.0 / 15).round(4))
|
10
10
|
end
|
11
11
|
end
|
metadata
CHANGED
@@ -1,97 +1,96 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slide_rule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mattnichols
|
8
8
|
- fergmastaflex
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-11-
|
12
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: levenshtein
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
16
|
requirements:
|
18
|
-
- -
|
17
|
+
- - ~>
|
19
18
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0
|
21
|
-
|
19
|
+
version: '1.0'
|
20
|
+
name: vladlev
|
22
21
|
prerelease: false
|
22
|
+
type: :runtime
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '0
|
27
|
+
version: '1.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name: rake
|
30
29
|
requirement: !ruby/object:Gem::Requirement
|
31
30
|
requirements:
|
32
|
-
- -
|
31
|
+
- - ~>
|
33
32
|
- !ruby/object:Gem::Version
|
34
33
|
version: '10'
|
35
|
-
|
34
|
+
name: rake
|
36
35
|
prerelease: false
|
36
|
+
type: :development
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '10'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name: pry
|
44
43
|
requirement: !ruby/object:Gem::Requirement
|
45
44
|
requirements:
|
46
|
-
- -
|
45
|
+
- - ~>
|
47
46
|
- !ruby/object:Gem::Version
|
48
47
|
version: '0'
|
49
|
-
|
48
|
+
name: pry
|
50
49
|
prerelease: false
|
50
|
+
type: :development
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name: rspec
|
58
57
|
requirement: !ruby/object:Gem::Requirement
|
59
58
|
requirements:
|
60
|
-
- -
|
59
|
+
- - ~>
|
61
60
|
- !ruby/object:Gem::Version
|
62
61
|
version: '3'
|
63
|
-
|
62
|
+
name: rspec
|
64
63
|
prerelease: false
|
64
|
+
type: :development
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '3'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name: rubocop
|
72
71
|
requirement: !ruby/object:Gem::Requirement
|
73
72
|
requirements:
|
74
|
-
- -
|
73
|
+
- - ~>
|
75
74
|
- !ruby/object:Gem::Version
|
76
75
|
version: '0'
|
77
|
-
|
76
|
+
name: rubocop
|
78
77
|
prerelease: false
|
78
|
+
type: :development
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ~>
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
-
description: Calculates the distance between 2 arbitrary objects using specified fields
|
85
|
-
and algorithms.
|
84
|
+
description: Calculates the distance between 2 arbitrary objects using specified fields and algorithms.
|
86
85
|
email:
|
87
86
|
- dev@mx.com
|
88
87
|
executables: []
|
89
88
|
extensions: []
|
90
89
|
extra_rdoc_files: []
|
91
90
|
files:
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
91
|
+
- .gitignore
|
92
|
+
- .rubocop.yml
|
93
|
+
- .travis.yml
|
95
94
|
- CODE_OF_CONDUCT.md
|
96
95
|
- Gemfile
|
97
96
|
- LICENSE
|
@@ -113,24 +112,24 @@ homepage: https://github.com/mattnichols/slide_rule
|
|
113
112
|
licenses:
|
114
113
|
- MIT
|
115
114
|
metadata: {}
|
116
|
-
post_install_message:
|
115
|
+
post_install_message:
|
117
116
|
rdoc_options: []
|
118
117
|
require_paths:
|
119
118
|
- lib
|
120
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
121
120
|
requirements:
|
122
|
-
- -
|
121
|
+
- - '>='
|
123
122
|
- !ruby/object:Gem::Version
|
124
123
|
version: '0'
|
125
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
125
|
requirements:
|
127
|
-
- -
|
126
|
+
- - '>='
|
128
127
|
- !ruby/object:Gem::Version
|
129
128
|
version: '0'
|
130
129
|
requirements: []
|
131
|
-
rubyforge_project:
|
132
|
-
rubygems_version: 2.4.
|
133
|
-
signing_key:
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.4.5
|
132
|
+
signing_key:
|
134
133
|
specification_version: 4
|
135
134
|
summary: Ruby object distance calculator
|
136
135
|
test_files:
|