Skip to content

Commit

Permalink
fix: simplify vegan/vegetarian ingredients analysis and merge 'ignore…
Browse files Browse the repository at this point in the history
…' and 'maybe' (#8849)
  • Loading branch information
stephanegigandet authored Aug 16, 2023
1 parent d2e5537 commit eaabdb8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
7 changes: 4 additions & 3 deletions lib/ProductOpener/Ingredients.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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}))
{
Expand Down
42 changes: 22 additions & 20 deletions taxonomies/ingredients.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

<en:juice
en:concentrated juice
Expand Down Expand Up @@ -60192,8 +60194,8 @@ zh:食品添加剂
wikidata:en:Q2596997
wikipedia:en:https://en.wikipedia.org/wiki/Condiment
# ingredient/fr:condiment has 360 products in 6 languages @2019-03-09
vegan:en:ignore
vegetarian:en:ignore
vegan:en:maybe
vegetarian:en:maybe

<en:condiment
en:powdered condiment
Expand Down Expand Up @@ -81768,8 +81770,8 @@ wikidata:en:Q636056
wikipedia:en:https://en.wikipedia.org/wiki/Purée
# ingredient/fr:purée has 151 products @2018-10-05
# used only to qualify another ingredient, ignore for ingredient analysis
vegan:en:ignore
vegetarian:en:ignore
vegan:en:maybe
vegetarian:en:maybe

<en:purée
en:concentrated purée
Expand Down Expand Up @@ -82255,8 +82257,8 @@ wikidata:en:Q745361
wikipedia:en:https://en.wikipedia.org/wiki/Stuffing
# ingredient/fr:garniture has 1531 products in 9 languages @2018-12-01
# ingredient/fr:farce has 884 products in 6 languages @2019-05-18
vegan:en:ignore
vegetarian:en:ignore
vegan:en:maybe
vegetarian:en:maybe

<en:filling
en:apricot filling
Expand Down Expand Up @@ -82639,8 +82641,8 @@ ciqual_proxy_food_code:en:9810
ciqual_proxy_food_name:fr:Pâtes sèches standard, crues
# ingredient/fr:pâtes-alimentaires has 115 products 2019-05-20
# ingredient/paste has 1809 products @2018-12-10
vegan:en:ignore
vegetarian:en:ignore
vegan:en:maybe
vegetarian:en:maybe

<en:pasta
en:durum wheat semolina pasta
Expand Down Expand Up @@ -83039,8 +83041,8 @@ ta:நூடுல்ஸ்
wikidata:en:q192874
wikipedia:en:https://en.wikipedia.org/wiki/Noodle
# ingredient/fr:nouilles has 241 products in 7 languages @2019-05-08
vegan:en:ignore
vegetarian:en:ignore
vegan:en:maybe
vegetarian:en:maybe
carbon_footprint_fr_foodges_ingredient:fr:Pâte à tarte
carbon_footprint_fr_foodges_value:fr:7.3

Expand Down Expand Up @@ -84190,8 +84192,8 @@ tr:kaplama
# usage:fr:Enrobage:farines (blé, seigle, et riz) (contient gluten) eau, amidon modifié, amidon et protéines de blé (contient gluten ), sel
# ingredient/fr:enrobant has 79 products in 4 languages @2019-02-21
# coating (water, wheat flour, modified corn starch, gluten of wheat, corn flour, corn starch, salt, potato starch)
vegan:en:ignore
vegetarian:en:ignore
vegan:en:maybe
vegetarian:en:maybe

<en:coating
en:cocoa coating
Expand Down Expand Up @@ -85727,8 +85729,8 @@ nl:korst
# usage:fr: croûte: herbes aromatiques bio
# usage:fr: conservateur (croûte) : natamycine (contient lait)
# usage/de: Kruste (mit Farbstoff [E 160b])
vegan:en:ignore
vegetarian:en:ignore
vegan:en:maybe
vegetarian:en:maybe

# description:en:The outer layer of cheese. Mostly for cheeses that have a distinctive layer different from the cheese itself.

Expand Down Expand Up @@ -86078,8 +86080,8 @@ en:jam
de:Marmelade de:Konfitüre
pl:dżem
ru:джем, повидло, варенье
vegan:en:ignore
vegetarian:en:ignore
vegan:en:maybe
vegetarian:en:maybe

###################################################################################################
#
Expand Down Expand Up @@ -86213,8 +86215,8 @@ zh:醬
wikidata:en:Q178359
wikipedia:en:https://en.wikipedia.org/wiki/Sauce
# ingredient/sauce has 5701 products in 15 languages @2019-05-02
vegan:en:ignore
vegetarian:en:ignore
vegan:en:maybe
vegetarian:en:maybe
nova:en:3

<en:sauce
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
],
"ingredients_analysis" : {
"en:maybe-vegetarian" : [
"en:mozzarella",
"en:rennet"
],
"en:non-vegan" : [
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/expected_test_results/ingredients/ja-parenthesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
"percent_max" : 100,
"percent_min" : 10,
"text" : "本醸造",
"vegan" : "ignore",
"vegetarian" : "ignore"
"vegan" : "maybe",
"vegetarian" : "maybe"
}
],
"percent_estimate" : 55,
"percent_max" : 100,
"percent_min" : 10,
"text" : "しょうゆ",
"vegan" : "ignore",
"vegetarian" : "ignore"
"vegan" : "maybe",
"vegetarian" : "maybe"
},
{
"id" : "ja:糖類",
Expand Down Expand Up @@ -64,8 +64,8 @@
"percent_max" : 33.3333333333333,
"percent_min" : 0,
"text" : "みりん",
"vegan" : "ignore",
"vegetarian" : "ignore"
"vegan" : "maybe",
"vegetarian" : "maybe"
},
{
"ciqual_food_code" : "11058",
Expand Down Expand Up @@ -126,8 +126,8 @@
"percent_max" : 11.1111111111111,
"percent_min" : 0,
"text" : "調味料",
"vegan" : "ignore",
"vegetarian" : "ignore"
"vegan" : "maybe",
"vegetarian" : "maybe"
},
{
"ciqual_food_code" : "1014",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"percent_max" : 70,
"percent_min" : 70,
"text" : "Garniture",
"vegan" : "ignore",
"vegetarian" : "ignore"
"vegan" : "maybe",
"vegetarian" : "maybe"
},
{
"id" : "en:pizza-dough",
Expand Down

0 comments on commit eaabdb8

Please sign in to comment.