vchain_client 1.0.28 → 1.0.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vchain_client.rb +28 -1
- data/lib/vchain_client/decision_algos/vector_based_decision_algorithm.rb +100 -110
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1f4807b48a4f9413739fa4e70e8893a2983c735
|
4
|
+
data.tar.gz: d1c9938626a2eee59176a25805b8c347d14d3024
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d88b075784a56721ee059dd5dd6f326e61088d82bf8e34e41cdf4f9b3a4d4f082625066b29b1725faa34f28d7eada236fb5ebd32dd71edb2c0627b04cabb1480
|
7
|
+
data.tar.gz: 883ae1b950241dc09852446011119a43111a937185194efacb0c38a9c703dd3e4a4f1f2170005d7186e1e5416c29a33f7c8ad55c6988d37cde1c38a364dcb2d1
|
data/lib/vchain_client.rb
CHANGED
@@ -26,7 +26,7 @@ module VChainClient
|
|
26
26
|
|
27
27
|
DATA_POINT_VERSION = "1"
|
28
28
|
|
29
|
-
CLIENT_LIB_VERSION = "1.0.
|
29
|
+
CLIENT_LIB_VERSION = "1.0.29"
|
30
30
|
|
31
31
|
@config = nil
|
32
32
|
@log = nil
|
@@ -138,13 +138,25 @@ module VChainClient
|
|
138
138
|
def self.get_similar_credential_sets(type)
|
139
139
|
if type == FIELD_TYPE_TRAVEL_DOCUMENT_HASHED
|
140
140
|
output = []
|
141
|
+
# given_names
|
141
142
|
output.push(["type", "number", "surname", "birthdate"])
|
143
|
+
# surname
|
142
144
|
output.push(["type", "number", "given_names", "birthdate"])
|
145
|
+
# number
|
143
146
|
output.push(["type", "given_names", "surname", "birthdate"])
|
147
|
+
# birthdate
|
144
148
|
output.push(["type", "number", "given_names", "surname"])
|
149
|
+
# given_names + number
|
150
|
+
output.push(["type", "surname", "birthdate"])
|
151
|
+
# surname + number
|
152
|
+
output.push(["type", "given_names", "birthdate"])
|
153
|
+
# given_names + birthdate
|
145
154
|
output.push(["type", "number", "surname"])
|
155
|
+
# surname + birthdate
|
146
156
|
output.push(["type", "number", "given_names"])
|
157
|
+
# given_names + surname
|
147
158
|
output.push(["type", "number", "birthdate"])
|
159
|
+
|
148
160
|
return output
|
149
161
|
|
150
162
|
elsif type == FIELD_TYPE_TEST_DOCUMENT_HASHED
|
@@ -961,6 +973,21 @@ module VChainClient
|
|
961
973
|
|
962
974
|
data_points.each { |data_point|
|
963
975
|
|
976
|
+
if @config.key?("do_not_check") && @config["do_not_check"] == true
|
977
|
+
|
978
|
+
if !output.key?(data_point["doc_hash"])
|
979
|
+
output[data_point["doc_hash"]] = {}
|
980
|
+
end
|
981
|
+
if !output[data_point["doc_hash"]].key?(data_point["field_hash"])
|
982
|
+
output[data_point["doc_hash"]][data_point["field_hash"]] = 0
|
983
|
+
end
|
984
|
+
|
985
|
+
# add weight coming from the data_point
|
986
|
+
output[data_point["doc_hash"]][data_point["field_hash"]] += (1 * data_point["weight"].to_f)
|
987
|
+
|
988
|
+
next
|
989
|
+
end
|
990
|
+
|
964
991
|
if !data_point.key?("blockchain_reciepts")
|
965
992
|
if @log.error?
|
966
993
|
@log.error("[check] not a valid data point - no blockchain_reciepts key")
|
@@ -303,90 +303,113 @@ module VChainClient
|
|
303
303
|
total_response_weight += vector_weight
|
304
304
|
}
|
305
305
|
|
306
|
+
diff_variants = []
|
307
|
+
|
306
308
|
vectors.each { |vector|
|
307
309
|
|
308
310
|
vector_weight = self.get_vector_weight(vector, sent_type_credentials_fields)
|
309
311
|
vector_probability = (vector_weight / total_response_weight) * 100
|
310
312
|
|
311
|
-
|
312
|
-
|
313
|
-
compare_document = sent_document.clone
|
314
|
-
compare_document.delete("names")
|
313
|
+
compare_document = sent_document.clone
|
315
314
|
|
316
|
-
|
317
|
-
diff_fields = []
|
318
|
-
validated = {}
|
315
|
+
sent_names = compare_document["names"].clone
|
319
316
|
|
320
|
-
|
321
|
-
vector_fliped = {}
|
322
|
-
|
323
|
-
vector.each { |hashed_vector_field, vector_values|
|
324
|
-
if hashed_vector_field != "names_parts"
|
325
|
-
vector_fliped[vector_values[1]] = vector_values[2]
|
326
|
-
end
|
327
|
-
}
|
317
|
+
compare_document.delete("names")
|
328
318
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
compare_field_hashed = Digest::SHA512.hexdigest(compare_field)
|
319
|
+
# let's compare found vector with sent_document
|
320
|
+
diff_fields = []
|
321
|
+
validated = {}
|
333
322
|
|
334
|
-
|
335
|
-
|
336
|
-
vector_values = vector[compare_field_hashed]
|
323
|
+
# flip vector
|
324
|
+
vector_fliped = {}
|
337
325
|
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
326
|
+
vector.each { |hashed_vector_field, vector_values|
|
327
|
+
if hashed_vector_field != "names_parts"
|
328
|
+
vector_fliped[vector_values[1]] = vector_values[2]
|
329
|
+
end
|
330
|
+
}
|
343
331
|
|
344
|
-
|
345
|
-
|
346
|
-
|
332
|
+
# all fields except of names
|
333
|
+
compare_document.each { |compare_field, compared_value_hashed|
|
334
|
+
|
335
|
+
compare_field_hashed = Digest::SHA512.hexdigest(compare_field)
|
347
336
|
|
348
|
-
|
337
|
+
if vector.key?(compare_field_hashed)
|
338
|
+
|
339
|
+
vector_values = vector[compare_field_hashed]
|
349
340
|
|
341
|
+
if sent_document[vector_values[1]] != vector_values[0]
|
342
|
+
|
343
|
+
diff_fields.push(compare_field)
|
344
|
+
|
350
345
|
else
|
351
346
|
|
352
347
|
validated[compare_field] = {
|
353
|
-
"validations_weight" =>
|
348
|
+
"validations_weight" => vector_values[2]
|
354
349
|
}
|
355
350
|
|
356
351
|
end
|
357
|
-
}
|
358
352
|
|
359
|
-
|
360
|
-
|
361
|
-
if vector.key?("names_parts")
|
362
|
-
if vector["names_parts"].key?("surname")
|
353
|
+
else
|
363
354
|
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
355
|
+
validated[compare_field] = {
|
356
|
+
"validations_weight" => 0
|
357
|
+
}
|
358
|
+
|
359
|
+
end
|
360
|
+
}
|
361
|
+
|
362
|
+
# names
|
363
|
+
|
364
|
+
surname_matched = false
|
365
|
+
given_names_matched = false
|
366
|
+
|
367
|
+
if vector.key?("names_parts")
|
368
|
+
if vector["names_parts"].key?("surname")
|
369
|
+
|
370
|
+
validated["surname"] = {
|
371
|
+
"vector_values" => vector["names_parts"]["surname"],
|
372
|
+
"validations_weight" => vector_fliped["surname"]
|
373
|
+
}
|
374
|
+
|
375
|
+
surname_matched = true
|
376
|
+
|
372
377
|
else
|
373
378
|
diff_fields.push("surname")
|
374
379
|
end
|
380
|
+
else
|
381
|
+
diff_fields.push("surname")
|
382
|
+
end
|
375
383
|
|
376
|
-
|
377
|
-
|
384
|
+
if vector.key?("names_parts")
|
385
|
+
if vector["names_parts"].key?("given_names")
|
378
386
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
end
|
387
|
+
validated["given_names"] = {
|
388
|
+
"vector_values" => vector["names_parts"]["given_names"],
|
389
|
+
"validations_weight" => vector_fliped["given_names"]
|
390
|
+
}
|
391
|
+
|
392
|
+
given_names_matched = true
|
393
|
+
|
387
394
|
else
|
388
395
|
diff_fields.push("given_names")
|
389
396
|
end
|
397
|
+
else
|
398
|
+
diff_fields.push("given_names")
|
399
|
+
end
|
400
|
+
|
401
|
+
if surname_matched && given_names_matched
|
402
|
+
diff = sent_names - vector["names_parts"]["surname"] - vector["names_parts"]["given_names"]
|
403
|
+
|
404
|
+
if diff.length > 0
|
405
|
+
diff_fields.push("surname")
|
406
|
+
diff_fields.push("given_names")
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
if vector_probability > PROBABILITY_THRESHOLD
|
411
|
+
|
412
|
+
## COULD MAKE A DECISION
|
390
413
|
|
391
414
|
if diff_fields.length == 0
|
392
415
|
return {
|
@@ -402,74 +425,41 @@ module VChainClient
|
|
402
425
|
"possible_mistakes" => diff_fields,
|
403
426
|
"validations" => validated
|
404
427
|
}
|
405
|
-
|
406
428
|
end
|
407
|
-
}
|
408
|
-
|
409
|
-
# prepare for output
|
410
|
-
|
411
|
-
vectors_fliped = []
|
412
|
-
|
413
|
-
for i in 0..(vectors.length - 1)
|
414
|
-
|
415
|
-
vector_fliped = {}
|
416
429
|
|
417
|
-
|
430
|
+
diff_variants.push(diff_fields)
|
431
|
+
}
|
418
432
|
|
419
|
-
|
420
|
-
|
421
|
-
if sent_document[vector_values[1]] != vector_values[0]
|
422
|
-
val = "different"
|
423
|
-
end
|
424
|
-
vector_fliped[vector_values[1]] = [val, vector_values[2]]
|
425
|
-
else
|
426
|
-
vector_fliped[hashed_vector_field] = vector_values
|
427
|
-
end
|
428
|
-
}
|
433
|
+
## ANALYSE DIFF_VARIANTS
|
434
|
+
all_the_same = true
|
429
435
|
|
430
|
-
|
431
|
-
if vector_fliped.key?("names_parts")
|
432
|
-
if vector_fliped["names_parts"].key?("surname")
|
433
|
-
sep = ""
|
434
|
-
vector_fliped["names_parts"]["surname"].each { |surname_part|
|
435
|
-
vector_raw_surname += sep + surname_part
|
436
|
-
sep = " "
|
437
|
-
}
|
438
|
-
else
|
439
|
-
vector_raw_surname = "different"
|
440
|
-
end
|
441
|
-
else
|
442
|
-
vector_raw_surname = "different"
|
443
|
-
end
|
436
|
+
prev_diff_fields = nil
|
444
437
|
|
445
|
-
|
446
|
-
if
|
447
|
-
if
|
448
|
-
|
449
|
-
|
450
|
-
vector_raw_given_names += sep + given_names_part
|
451
|
-
sep = " "
|
452
|
-
}
|
453
|
-
else
|
454
|
-
vector_raw_given_names = "different"
|
438
|
+
diff_variants.each { |diff_fields|
|
439
|
+
if prev_diff_fields != nil
|
440
|
+
if prev_diff_fields.uniq.sort != diff_fields.uniq.sort
|
441
|
+
all_the_same = false
|
442
|
+
break
|
455
443
|
end
|
456
|
-
else
|
457
|
-
vector_raw_given_names = "different"
|
458
444
|
end
|
459
445
|
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
vector_fliped.delete("names_parts")
|
464
|
-
|
465
|
-
vectors_fliped.push(vector_fliped)
|
446
|
+
prev_diff_fields = diff_fields
|
447
|
+
}
|
466
448
|
|
449
|
+
if all_the_same
|
450
|
+
return {
|
451
|
+
"decision_made" => true,
|
452
|
+
"decision" => "POSSIBLE_MISTAKES",
|
453
|
+
"possible_mistakes" => prev_diff_fields
|
454
|
+
}
|
467
455
|
end
|
468
456
|
|
469
457
|
return {
|
470
|
-
"decision_made"
|
471
|
-
"
|
458
|
+
"decision_made" => true,
|
459
|
+
"decision" => "POSSIBLE_MISTAKES",
|
460
|
+
"possible_mistakes" => diff_variants
|
472
461
|
}
|
462
|
+
|
473
463
|
end
|
474
464
|
|
475
465
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vchain_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksandr Gorelik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: log4r
|