Skip to content

Commit

Permalink
taxonomy: soy_sauce_vegan (#9589)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbenben2 authored Jan 30, 2024
1 parent 3f42fa7 commit 0708361
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 6 deletions.
19 changes: 15 additions & 4 deletions lib/ProductOpener/DataQualityFood.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1812,10 +1812,21 @@ sub check_labels ($product_ref) {
unshift @ingredients, @{$ingredient_ref->{ingredients}};
}

# some additives_classes (like thickener, for example) do not have the key-value vegan and vegetarian
# it can be additives_classes that contain only vegan/vegetarian additives.
# to avoid false-positive - instead of raising a warning (else below) we ignore additives_classes
if (!exists_taxonomy_tag("additives_classes", $ingredientid)) {
# - some additives_classes (like thickener, for example) do not have the key-value vegan and vegetarian
# it can be additives_classes that contain only vegan/vegetarian additives.
# - also we cannot tell if a compound ingredient (preparation) is vegan or vegetarian
# to handle both cases we ignore the ingredient having vegan/vegatarian "maybe" and if it contains sub-ingredients
my $ignore_vegan_vegetarian_facet = 0;
if (
(defined $ingredient_ref->{ingredients})
and ( ((defined $ingredient_ref->{"vegan"}) and ($ingredient_ref->{"vegan"} ne 'no'))
or ((defined $ingredient_ref->{"vegetarian"}) and ($ingredient_ref->{"vegetarian"} ne 'no')))
)
{
$ignore_vegan_vegetarian_facet = 1;
}

if (not $ignore_vegan_vegetarian_facet) {
if (has_tag($product_ref, "labels", "en:vegan")) {
# vegan
if (defined $ingredient_ref->{"vegan"}) {
Expand Down
20 changes: 20 additions & 0 deletions stop_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
acérola
acide
acidifiant
actionDetails
Agribalyse
AgriBalyse
AGS
Expand Down Expand Up @@ -37,6 +38,7 @@ canonicalizes
canonicalized
Canonicalizes
Carrefour
Catégorie
Catalogue
céléri
CIC
Expand All @@ -55,6 +57,7 @@ couvercle
Crowdin
csv
CSV
déc
d'acérola
d'olive
dans
Expand All @@ -73,7 +76,12 @@ EREN
et
Eurocode
Eurocodes
Evènement
eval
eventAction
eventCategory
eventName
eventValue
EXIF
Fabriqué
filehandle
Expand Down Expand Up @@ -114,6 +122,10 @@ hinnies
http
https
huile
iconSVG
idpageview
idSite
idVisit
incrontab
Ingrédients
Intermarché
Expand Down Expand Up @@ -175,6 +187,9 @@ OpenFoodFacts
Origine
overriden
packagings
pageId
pageIdAction
pageviewPosition
param
Pâtes
pectine
Expand Down Expand Up @@ -205,9 +220,11 @@ Robotoff
RTFSG
Santé
saturés
scanAction
scanbot
scrypt
Scrypt
serverTimePretty
sftp
sirop
slad
Expand Down Expand Up @@ -250,10 +267,13 @@ UUID
Valeur
vegetal
viande
visitIp
visitorId
vitamines
VPF
weigher
weighers
WpZhmY
www
xml
gzipped
Expand Down
7 changes: 5 additions & 2 deletions taxonomies/ingredients.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89133,6 +89133,8 @@ description:en:SOY SAUCE is a liquid condiment of Chinese origin, made from a fe
# zh-hant:醬油
# zh-tw:醬油
allergens:en: en:soybeans
vegan:en:maybe
vegetarian:en:maybe
wikidata:en:Q229385
wikipedia:en:https://en.wikipedia.org/wiki/Soy_sauce
# openfoodfacts:https://world.openfoodfacts.org/ingredient/fr:sauce-au-soja
Expand Down Expand Up @@ -89388,8 +89390,9 @@ zh:辣醬油
# zh-hk:辣醬油
wikidata:en:Q842618
wikipedia:en:https://en.wikipedia.org/wiki/Worcestershire_sauce
vegan:en:no
vegetarian:en:no
vegan:en:maybe
vegetarian:en:maybe
# usually contains anchovies
# ingredient/fr:sauce-worcestershire has 30 products in 3 languages @2019-04-30
# usage:de:Worcestershire Sauce (Malzessig, Melasse, Wasser, Kochsalz, Zwiebeln, Knoblauch, Zucker, Gewürze, Sardellen, Tamarindenextrakt, natürliche Aromen)

Expand Down
49 changes: 49 additions & 0 deletions tests/unit/dataqualityfood_labels.t
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,55 @@ check_quality_and_test_product_has_quality_tag(
'raise warning because vegetarian or non-vegetarian is unknown for an ingredient', 0
);

# ignore compunds
$product_ref = {
labels_tags => ["en:vegetarian", "en:vegan",],
ingredients => [
{
id => "en:lentils",
vegan => "yes",
vegetarian => "yes"
},
{
id => "en:worcester",
ingredients => [
{
id => "en:soy-sauce",
vegan => "yes",
vegetarian => "yes",
},
],
vegan => "maybe",
vegetarian => "maybe",
},
{
id => "en:honey",
vegan => "yes",
vegetarian => "yes"
}
],
};
check_quality_and_test_product_has_quality_tag(
$product_ref,
'en:vegan-label-but-non-vegan-ingredient',
'should not be raised when ingredient contain sub-ingredients', 0
);
check_quality_and_test_product_has_quality_tag(
$product_ref,
'en:vegetarian-label-but-non-vegetarian-ingredient',
'should not be raised when ingredient contain sub-ingredients', 0
);
check_quality_and_test_product_has_quality_tag(
$product_ref,
'en:vegan-label-but-could-not-confirm-for-all-ingredients',
'should not be raised when ingredient contain sub-ingredients', 0
);
check_quality_and_test_product_has_quality_tag(
$product_ref,
'en:vegetarian-label-but-could-not-confirm-for-all-ingredients',
'should not be raised when ingredient contain sub-ingredients', 0
);

# labels claim vs input nutrition data, based on EU regulation: https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A02006R1924-20141213
# TODO TESTS WITH CATEGORIES AND ALL LABELS IN CASE TAXO CHANGE OVER TIME, SO THAT IT IS DETECTED WHEN RUNNING TESTS
# product quantity warnings and errors
Expand Down

0 comments on commit 0708361

Please sign in to comment.