Skip to content

Commit

Permalink
Fix a minor error in reviews as price after fix
Browse files Browse the repository at this point in the history
- Fix a minor error in reviews as price after fix
- Bump up the version to push the recent gem
  • Loading branch information
kagermanov27 committed Jun 20, 2023
1 parent 89aee0a commit 8370cb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion google-local-results-ai-parser.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = "google-local-results-ai-parser"
spec.version = "0.1.3"
spec.version = "0.1.4"
spec.summary = "A gem to be used with serpapi/bert-base-local-results model to predict different parts of Google Local Listings."
spec.description = "A gem to be used with serpapi/bert-base-local-results model to predict different parts of Google Local Listings. This gem uses BERT model at https://huggingface.co/serpapi/bert-base-local-results in the background. For serving private servers, head to https://github.com/serpapi/google-local-results-ai-server to get more information."
spec.homepage = "https://github.com/serpapi/google-local-results-ai-parser"
Expand Down
12 changes: 6 additions & 6 deletions lib/google-local-results-ai-parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,16 @@ def reviews_as_price_confusion(results, label_order, duplicates)
# Zero out the `price`, and put it to last position
reviews_hash = results[price_duplicate[-1]][:result][0].find {|hash| hash["label"] == "reviews" }
reviews_index = results[price_duplicate[-1]][:result][0].index(reviews_hash)
results[price_duplicate[-1]][:result][0][0] = {"label" => "reviews", "score" => 1.0}
results[price_duplicate[-1]][:result][0].delete_at(reviews_index)
results[price_duplicate[-1]][:result][0] << {"label" => "price", "score" => 0.0}
results[price_duplicate[0]][:result][0][0] = {"label" => "reviews", "score" => 1.0}
results[price_duplicate[0]][:result][0].delete_at(reviews_index)
results[price_duplicate[0]][:result][0] << {"label" => "price", "score" => 0.0}

# Rearranging `label_order`
label_order[price_duplicate[-1]] = "reviews"
label_order[price_duplicate[0]] = "reviews"

# Rearranging duplicates
last_item = duplicates[duplicates.index(price_duplicate)][-1]
duplicates[duplicates.index(price_duplicate)].delete(last_item)
first_item = duplicates[duplicates.index(price_duplicate)][0]
duplicates[duplicates.index(price_duplicate)].delete(first_item)

if (duplicate_arr = duplicates[duplicates.index(price_duplicate)]) && duplicate_arr.size == 1
duplicates.delete(duplicate_arr)
Expand Down

0 comments on commit 8370cb1

Please sign in to comment.