From eaabdb8b6d8ba3251cf837598b31a5b309906bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Wed, 16 Aug 2023 10:15:33 +0200 Subject: [PATCH] fix: simplify vegan/vegetarian ingredients analysis and merge 'ignore' and 'maybe' (#8849) --- lib/ProductOpener/Ingredients.pm | 7 ++-- taxonomies/ingredients.txt | 42 ++++++++++--------- .../ingredients/ca-middle-dot.json | 1 - .../ingredients/ja-parenthesis.json | 16 +++---- ...rgherita-pizza-2-compound-ingredients.json | 4 +- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/lib/ProductOpener/Ingredients.pm b/lib/ProductOpener/Ingredients.pm index 29879f6a83e79..3bb1071b902c1 100644 --- a/lib/ProductOpener/Ingredients.pm +++ b/lib/ProductOpener/Ingredients.pm @@ -3181,9 +3181,10 @@ sub analyze_ingredients ($product_ref) { } } - # Vegetable oil (rapeseed oil, ...) : ignore "from_palm_oil:en:maybe" if the ingredient has sub-ingredients - if ( ($property eq "from_palm_oil") - and (defined $value) + # if the property value is "maybe" and the ingredient has sub-ingredients, + # we ignore the ingredient and only look at its sub-ingredients (already added) + # e.g. "Vegetable oil (rapeseed oil, ...)"" + if ( (defined $value) and ($value eq "maybe") and (defined $ingredient_ref->{ingredients})) { diff --git a/taxonomies/ingredients.txt b/taxonomies/ingredients.txt index 1492a148f5014..e4eba15a3cdcd 100644 --- a/taxonomies/ingredients.txt +++ b/taxonomies/ingredients.txt @@ -1,3 +1,5 @@ +# properties vegan:en, vegetarian:en and from_palm_oil:en can have values yes, no, maybe +# in the case of maybe, if the ingredient has sub-ingredients, then only its sub-ingredients are considered #comment:en:These are synonyms of ingredients @@ -35431,8 +35433,8 @@ pl:sok, soki, soku, soków pt:Sumo ru:Сок # ingredient/fr:jus has 156 products in 4 languages @2019-02-02 -vegan:en:ignore -vegetarian:en:ignore +vegan:en:maybe +vegetarian:en:maybe