Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: solve quantity false positives issue #2037 #2038

Merged
merged 7 commits into from
May 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/ProductOpener/SiteQuality_off.pm
Original file line number Diff line number Diff line change
Expand Up @@ -738,13 +738,15 @@ sub check_ingredients($) {
}


# Check quantity values. See https://en.wiki.openfoodfacts.org/Products_quantities
sub check_quantity($) {

my $product_ref = shift;

# quantity contains "e" - might be an indicator that the user might have wanted to use "℮" \N{U+212E}
# example: 650 g e
if ((defined $product_ref->{quantity})
and ($product_ref->{quantity} =~ /(?:.*e$)|(?:[0-9]+\s*[kmc]?[gl]?\s*e)/i)
and ($product_ref->{quantity} =~ /(?:^e\s)|(?:\se[^a-z])|(?:\se$)/i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of the more complex regexp was to flag things like this : "500 ge"

and (not ($product_ref->{quantity} =~ /\N{U+212E}/i))) {
push @{$product_ref->{quality_tags}}, "quantity-contains-e";
}
Expand Down