wolf_core 1.1.26 → 1.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/wolf_core/utils/string_utils.rb +64 -4
- data/lib/wolf_core/version.rb +1 -1
- data/lib/wolf_core.rb +0 -1
- metadata +1 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 91b0f1648e9860c15214dc810166b4588c72b4ca4db3bb2f277d70b45b1340de
|
|
4
|
+
data.tar.gz: df8d5a91a1be6af9e333639cbedb60ac760c6872a814b915c26847f5151ce466
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f41961527ded090fe4bf7338f90a77294bfe2b1556613bd2565682edab5cc27c47361cf5daf080cf35a02ecb88710b0bd4775c027d5a2643c3ccbef3ffaa856
|
|
7
|
+
data.tar.gz: b253298cd99e4ffcece5f536e7117e25c5397d7570c827211f71161bf5d95d27594f2e4d5989556f0433724371961b2a0b2026a602e0ca41e112a1b7f882cf98
|
|
@@ -145,10 +145,70 @@ module WolfCore
|
|
|
145
145
|
{ first_name: name, last_name: lastname }
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
-
def jaro_winkler_similarity(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
def jaro_winkler_similarity(string1, string2)
|
|
149
|
+
str1 = string1.to_s.strip.downcase
|
|
150
|
+
str2 = string2.to_s.strip.downcase
|
|
151
|
+
|
|
152
|
+
return 1.0 if str1 == str2
|
|
153
|
+
return 0.0 if str1.empty? || str2.empty?
|
|
154
|
+
|
|
155
|
+
max_len = [str1.length, str2.length].max
|
|
156
|
+
match_distance = [(max_len / 2) - 1, 0].max
|
|
157
|
+
|
|
158
|
+
str1_matches = Array.new(str1.length, false)
|
|
159
|
+
str2_matches = Array.new(str2.length, false)
|
|
160
|
+
|
|
161
|
+
matches = 0
|
|
162
|
+
|
|
163
|
+
str1.each_char.with_index do |char, i|
|
|
164
|
+
start = [i - match_distance, 0].max
|
|
165
|
+
finish = [i + match_distance + 1, str2.length].min
|
|
166
|
+
|
|
167
|
+
(start...finish).each do |j|
|
|
168
|
+
next if str2_matches[j]
|
|
169
|
+
next unless str2[j] == char
|
|
170
|
+
|
|
171
|
+
str1_matches[i] = true
|
|
172
|
+
str2_matches[j] = true
|
|
173
|
+
matches += 1
|
|
174
|
+
break
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
return 0.0 if matches.zero?
|
|
179
|
+
|
|
180
|
+
transpositions = 0
|
|
181
|
+
j = 0
|
|
182
|
+
|
|
183
|
+
str1.each_char.with_index do |char, i|
|
|
184
|
+
next unless str1_matches[i]
|
|
185
|
+
|
|
186
|
+
j += 1 while j < str2.length && !str2_matches[j]
|
|
187
|
+
break if j >= str2.length
|
|
188
|
+
|
|
189
|
+
transpositions += 1 if str2[j] != char
|
|
190
|
+
j += 1
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
transpositions /= 2.0
|
|
194
|
+
|
|
195
|
+
jaro = (
|
|
196
|
+
(matches / str1.length.to_f) +
|
|
197
|
+
(matches / str2.length.to_f) +
|
|
198
|
+
((matches - transpositions) / matches)
|
|
199
|
+
) / 3.0
|
|
200
|
+
|
|
201
|
+
prefix_length = 0
|
|
202
|
+
max_prefix = 4
|
|
203
|
+
while prefix_length < max_prefix &&
|
|
204
|
+
prefix_length < str1.length &&
|
|
205
|
+
prefix_length < str2.length &&
|
|
206
|
+
str1[prefix_length] == str2[prefix_length]
|
|
207
|
+
prefix_length += 1
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
jaro + (prefix_length * 0.1 * (1 - jaro))
|
|
152
211
|
end
|
|
212
|
+
|
|
153
213
|
end
|
|
154
214
|
end
|
data/lib/wolf_core/version.rb
CHANGED
data/lib/wolf_core.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wolf_core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.28
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Javier Roncallo
|
|
@@ -121,20 +121,6 @@ dependencies:
|
|
|
121
121
|
- - ">="
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
123
|
version: '0'
|
|
124
|
-
- !ruby/object:Gem::Dependency
|
|
125
|
-
name: jaro_winkler
|
|
126
|
-
requirement: !ruby/object:Gem::Requirement
|
|
127
|
-
requirements:
|
|
128
|
-
- - ">="
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: '0'
|
|
131
|
-
type: :runtime
|
|
132
|
-
prerelease: false
|
|
133
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
134
|
-
requirements:
|
|
135
|
-
- - ">="
|
|
136
|
-
- !ruby/object:Gem::Version
|
|
137
|
-
version: '0'
|
|
138
124
|
description: Repository to store shared code among Ruby projects.
|
|
139
125
|
email:
|
|
140
126
|
- jroncallo96@gmail.com
|