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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78ecf24cc717254a2d3b597868e582f715fc86c7ca160aadbdef5183a3cdb9e7
4
- data.tar.gz: '09818139bdc702f86693ff1b48519b6ecbc1d4a5264d9969faf315a04fa901f2'
3
+ metadata.gz: 9f8076de3793dabc268bc5705443e28202655e26c5a1503498767e1b8a62ff16
4
+ data.tar.gz: 7e3cf96add3d90d2e6174f9acda7f6cd8357f2f06792d46fc308aa80cc7fa93f
5
5
  SHA512:
6
- metadata.gz: e69e9916971731c5461b3060c558b84e5373a411197b7cd90252601f9ce35d8b07ab9854a5d8663ea6b9f70c21d94f4aa37e182e0956e320e44c687c36ef06e9
7
- data.tar.gz: 1e34f84316101ba580189b4b783f42a20c814f3ae1b2e4337a7f46373c842de492bde9f54448e86f02432327309649d0a38d973129ac946bbe3bc39b193f3f4c
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 = duplicates.select.with_index do |duplicate, duplicate_index|
471
- caught_results_indices.each do |caught_index|
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[duplicates.index(not_service_option_duplicate)][-1]
495
- duplicates[duplicates.index(not_service_option_duplicate)].delete(last_item)
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[duplicates.index(not_service_option_duplicate)]) && duplicate_arr.size == 1
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-local-results-ai-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emirhan Akdeniz