google-local-results-ai-parser 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google-local-results-ai-parser.rb +9 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f8076de3793dabc268bc5705443e28202655e26c5a1503498767e1b8a62ff16
|
4
|
+
data.tar.gz: 7e3cf96add3d90d2e6174f9acda7f6cd8357f2f06792d46fc308aa80cc7fa93f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91c997a71f5765a0d43cc1c4418cecc1a83b00eb3b418f4aed6802a1c5fa78391b337384433147cf5c7eb8af5455ad07289f8440c31e58585493978d4673394a
|
7
|
+
data.tar.gz: b0d1a462cba2a8097c0bc54ec0142e78b5d7daffe5c5ed4c663ddb7522c35391ee4ba9587f803a711f2e0fbe7395ab7d353254eda6ecab6212bbeed64c563b4d
|
@@ -465,16 +465,18 @@ module GoogleLocalResultsAiParser
|
|
465
465
|
"Takeaway"
|
466
466
|
]
|
467
467
|
caught_results_indices = results.map.with_index {|result, index| index if known_errors.include?(result[:input])}.compact
|
468
|
-
return results, label_order, duplicates if caught_results_indices == []
|
469
468
|
|
470
|
-
not_service_option_duplicates =
|
471
|
-
|
469
|
+
not_service_option_duplicates = []
|
470
|
+
caught_results_indices.each do |caught_index|
|
471
|
+
duplicates.each.with_index do |duplicate, duplicate_index|
|
472
472
|
if duplicate.include?(caught_index) && results[caught_index][:result][0][0]["label"] != "service_options"
|
473
|
-
duplicate_index
|
473
|
+
not_service_option_duplicates << duplicate_index
|
474
474
|
end
|
475
475
|
end
|
476
476
|
end
|
477
477
|
|
478
|
+
already_a_service_option = caught_results_indices.all? {|index| results[index][:result][0][0]["label"] == "service options"}
|
479
|
+
return results, label_order, duplicates if already_a_service_option
|
478
480
|
# Zero out the `type` or `description`, and put it to last position
|
479
481
|
caught_results_indices.each do |caught_index|
|
480
482
|
service_options_hash = results[caught_index][:result][0].find {|hash| hash["label"] == "service options" }
|
@@ -491,12 +493,12 @@ module GoogleLocalResultsAiParser
|
|
491
493
|
|
492
494
|
# Rearranging duplicates
|
493
495
|
not_service_option_duplicates.each do |not_service_option_duplicate|
|
494
|
-
last_item = duplicates[
|
495
|
-
duplicates[
|
496
|
+
last_item = duplicates[not_service_option_duplicate][-1]
|
497
|
+
duplicates[not_service_option_duplicate].delete(last_item)
|
496
498
|
end
|
497
499
|
|
498
500
|
not_service_option_duplicates.each do |not_service_option_duplicate|
|
499
|
-
if (duplicate_arr = duplicates[
|
501
|
+
if (duplicate_arr = duplicates[not_service_option_duplicate]) && duplicate_arr.size == 1
|
500
502
|
duplicates.delete(duplicate_arr)
|
501
503
|
end
|
502
504
|
end
|