Skip to content

Commit

Permalink
fix: compute ecoscore bonuses for all categories (#8629)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanegigandet committed Jun 29, 2023
1 parent 166b4c9 commit 2be152e
Show file tree
Hide file tree
Showing 8 changed files with 961 additions and 23 deletions.
15 changes: 8 additions & 7 deletions lib/ProductOpener/Ecoscore.pm
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,14 @@ sub compute_ecoscore ($product_ref) {
}
}

# Always compute the bonuses and maluses, even for categories that don't have Eco-Score
#聽(e.g. sodas, spring water)

compute_ecoscore_production_system_adjustment($product_ref);
compute_ecoscore_threatened_species_adjustment($product_ref);
compute_ecoscore_origins_of_ingredients_adjustment($product_ref);
compute_ecoscore_packaging_adjustment($product_ref);

if ($category_without_ecoscore) {
$product_ref->{ecoscore_data}{ecoscore_not_applicable_for_category} = $category_without_ecoscore;
$product_ref->{ecoscore_data}{status} = "unknown";
Expand All @@ -753,13 +761,6 @@ sub compute_ecoscore ($product_ref) {

compute_ecoscore_agribalyse($product_ref);

# Compute the bonuses and maluses

compute_ecoscore_production_system_adjustment($product_ref);
compute_ecoscore_threatened_species_adjustment($product_ref);
compute_ecoscore_origins_of_ingredients_adjustment($product_ref);
compute_ecoscore_packaging_adjustment($product_ref);

# Compute the final Eco-Score and assign the A to E grade

# We need an AgriBalyse category match to compute the Eco-Score
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Canola Oil, Water, Garbanzo Beans, Lupin (bean), Mustard Seeds, Grape Vinegar, L
3451790834080 29135200 fr UHT sterilised semi-skimmed milk enriched with vitamins B1, B2, B5, B12 and D - Long life Lait demi ecr茅m茅 Vitamin enriched milk Semi-skimmed milk Lait demi-茅cr茅m茅 st茅rilis茅 UHT enrichi en vitamines B1, B2, B5, B12 et D - longue conservation 1 l "Plastique, Bouchon en poly茅thyl猫ne, Bouteille en Poly茅thyl猫ne, Opercule en mat茅riau composite, 脡tiquette en papier" en:plastic,fr:bouchon-en-polyethylene,fr:bouteille-en-polyethylene,fr:opercule-en-materiau-composite,fr:etiquette-en-papier Elle & Vire, Savencia, Elle&Vire International elle-vire,savencia,elle-vire-international Savencia Produits laitiers, Cr猫mes, Laits, Laits homog茅n茅is茅s, Laits demi-茅cr茅m茅s, Laits UHT, Cr猫mes enti猫res, Cr猫mes cuisson en:dairies,en:creams,en:milks,en:homogenized-milks,en:semi-skimmed-milks,en:uht-milks,fr:cremes-entieres,fr:cremes-cuisson Enrichi en vitamines, Fabriqu茅 en France en:enriched-wih-vitamins,en:made-in-france France en:france Toutes enseignes GMS toutes-enseignes-gms France en:france France, Somme france,somme FR 80.001.002 EC, FR 50.139.001 EC fr-80-001-002-ec,fr-50-139-001-ec Milk Leche _Lait_ demi-茅cr茅m茅 st茅rilis茅 UHT enrichi en vitamines B1, B2, B5, B12 et D. Leite Lait en:milk 100g 100g 193 kJ 46 kcal 1.55 g 1.1 g 4.8 g 4.8 g 0 g 3.2 g 0.13 g 0.052 g 193 kJ 120 mg 21.875 g https://www.elle-et-vire.com/en/produits/lait/bouteilles/lait-demi-ecreme-vitamine-uht/ en:milk-and-yogurt en:milk-and-dairy-products,en:milk-and-yogurt 1 en:1-unprocessed-or-minimally-processed-foods b 1 b 60 1 19041 19 -15 1 0 App - yuka, Apps, Producers, Producer - elle-vire 0
3760178254021 fr Chocolat au lait France en:france 100g 100g 148 kcal 9.2 g 5.4 g 13 g 13 g 3.4 g 148 kcal unknown unknown 1 -5 -15 1 0 App - yuka, Apps 0
29161690 fr 100 % Almond Buter 227 g France en:france 100g 100g 635 kcal 54.9 g 5.4 g 27.6 g 3.4 g 21 g 635 kcal unknown unknown 1 -5 -15 1 0 App - yuka, Apps 0
3770013801303 fr Limonade Boissons, Boissons gazeuses, Sodas, Limonades en:beverages,en:carbonated-drinks,en:sodas,en:lemonade Bio en:organic France en:france 100g 100g 31.2 kcal 1 g 1 g 7.5 g 7.5 g 1 g 0.7 g 31.2 kcal en:sweetened-beverages en:beverages,en:sweetened-beverages unknown not-applicable App - yuka, Apps 0
25000044984 en Simply lemonade Simply Lemonade 8 OZA (240 ml) The Minute Maid Company Beverages, Carbonated drinks, Sodas, Lemonade, Sweetened beverages en:beverages,en:carbonated-drinks,en:sodas,en:lemonade,en:sweetened-beverages France, United States en:france,en:united-states Contains pure filtered water, lemon juice, cane sugar, natural flavors. Contains pure filtered water, lemon juice, cane sugar, natural flavors. 100g 100g 50 kcal 0 g 0 g 12.5 g 11.67 g 0 g 0.0159 g 0.00636 g 50 kcal en:sweetened-beverages en:beverages,en:sweetened-beverages 4 en:4-ultra-processed-food-and-drink-products e 15 not-applicable 2019-07-29T00:00:00Z Soda LI 678078 2019-07-29T00:00:00Z 2019-12-06T00:00:00Z App - yuka, Apps, Databases, database-usda, App - InFood 0
3770013801303 fr Limonade Boissons, Boissons gazeuses, Sodas, Limonades en:beverages,en:carbonated-drinks,en:sodas,en:lemonade Bio en:organic France en:france 100g 100g 31.2 kcal 1 g 1 g 7.5 g 7.5 g 1 g 0.7 g 31.2 kcal en:sweetened-beverages en:beverages,en:sweetened-beverages unknown not-applicable 1 -5 -15 1 0 App - yuka, Apps 0
25000044984 en Simply lemonade Simply Lemonade 8 OZA (240 ml) The Minute Maid Company Beverages, Carbonated drinks, Sodas, Lemonade, Sweetened beverages en:beverages,en:carbonated-drinks,en:sodas,en:lemonade,en:sweetened-beverages France, United States en:france,en:united-states Contains pure filtered water, lemon juice, cane sugar, natural flavors. Contains pure filtered water, lemon juice, cane sugar, natural flavors. 100g 100g 50 kcal 0 g 0 g 12.5 g 11.67 g 0 g 0.0159 g 0.00636 g 50 kcal en:sweetened-beverages en:beverages,en:sweetened-beverages 4 en:4-ultra-processed-food-and-drink-products e 15 not-applicable 1 -5 -15 1 0 2019-07-29T00:00:00Z Soda LI 678078 2019-07-29T00:00:00Z 2019-12-06T00:00:00Z App - yuka, Apps, Databases, database-usda, App - InFood 0
80650904 fr Olio aromatizzato funghi e tartufo France en:france 100g 100g unknown unknown 1 -5 -15 1 0 App - yuka, Apps 0
9002355004345 de Tiroler Fr眉chtek眉che Marillen 420 g Glas en:glass Tiroler Fr眉chtek眉che tiroler-fruchtekuche "Pflanzliche Lebensmittel und Getr盲nke, Pflanzliche Lebensmittel, Fr眉hst眉cke, Frucht- und gem眉sebasierte Lebensmittel, Brotaufstriche, Fruchtbasierte Lebensmittel, Pflanzliche Brotaufstriche, S眉脽e Brotaufstriche, Konfit眉ren und Marmeladen, Konfit眉ren" en:plant-based-foods-and-beverages,en:plant-based-foods,en:breakfasts,en:fruits-and-vegetables-based-foods,en:spreads,en:fruits-based-foods,en:plant-based-spreads,en:sweet-spreads,en:fruit-and-vegetable-preserves,en:jams Frankreich, Deutschland en:france,en:germany 100g 100g 224 kcal 0 g 0 g 54 g 53 g 0 g 0 g 0 g 224 kcal en:sweets en:sugary-snacks,en:sweets unknown c 7 b 60 1 31024 -5 -15 1 0 App - yuka, Apps 0
26281742 en Stawberry jam Strawberry conserve 500 g serving fr:bocal verre fr:bocal-verre Grandessa grandessa Plant-based foods and beverages, Plant-based foods, Breakfasts, Spreads, Plant-based spreads, Sweet spreads, Fruit and vegetable preserves en:plant-based-foods-and-beverages,en:plant-based-foods,en:breakfasts,en:spreads,en:plant-based-spreads,en:sweet-spreads,en:fruit-and-vegetable-preserves Made in Belgium en:made-in-belgium France en:france made in belgium made-in-belgium Eggs, Milk en:eggs,en:milk serving 100g 171 kcal 0.1 g 0.1 g 9.9 g 9.9 g 0.1 g 2.54 g 1.016 g 171 kcal en:sweets en:sugary-snacks,en:sweets unknown unknown 1 -5 -15 1 0 App - yuka, Apps 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
"nutrition_data_per" : "100g",
"nutrition_data_prepared_per" : "100g",
"obsolete" : "0",
"off:ecoscore_data.adjustments.origins_of_ingredients.value" : "",
"off:ecoscore_data.adjustments.packaging.non_recyclable_and_non_biodegradable_materials" : "",
"off:ecoscore_data.adjustments.packaging.value" : "",
"off:ecoscore_data.adjustments.production_system.value" : "",
"off:ecoscore_data.adjustments.origins_of_ingredients.value" : "-5",
"off:ecoscore_data.adjustments.packaging.non_recyclable_and_non_biodegradable_materials" : "1",
"off:ecoscore_data.adjustments.packaging.value" : "-15",
"off:ecoscore_data.adjustments.production_system.value" : "0",
"off:ecoscore_data.adjustments.threatened_species.value" : "",
"off:ecoscore_data.agribalyse.code" : "",
"off:ecoscore_data.missing_key_data" : "",
"off:ecoscore_data.missing_key_data" : "1",
"off:ecoscore_grade" : "not-applicable",
"off:ecoscore_score" : "",
"off:food_groups" : "en:sweetened-beverages",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
"nutrition_data_per" : "100g",
"nutrition_data_prepared_per" : "100g",
"obsolete" : "0",
"off:ecoscore_data.adjustments.origins_of_ingredients.value" : "",
"off:ecoscore_data.adjustments.packaging.non_recyclable_and_non_biodegradable_materials" : "",
"off:ecoscore_data.adjustments.packaging.value" : "",
"off:ecoscore_data.adjustments.production_system.value" : "",
"off:ecoscore_data.adjustments.origins_of_ingredients.value" : "-5",
"off:ecoscore_data.adjustments.packaging.non_recyclable_and_non_biodegradable_materials" : "1",
"off:ecoscore_data.adjustments.packaging.value" : "-15",
"off:ecoscore_data.adjustments.production_system.value" : "0",
"off:ecoscore_data.adjustments.threatened_species.value" : "",
"off:ecoscore_data.agribalyse.code" : "",
"off:ecoscore_data.missing_key_data" : "",
"off:ecoscore_data.missing_key_data" : "1",
"off:ecoscore_grade" : "not-applicable",
"off:ecoscore_score" : "",
"off:food_groups" : "en:sweetened-beverages",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,235 @@
"en:sodas"
],
"ecoscore_data" : {
"adjustments" : {},
"adjustments" : {
"origins_of_ingredients" : {
"aggregated_origins" : [
{
"origin" : "en:unknown",
"percent" : 100
}
],
"epi_score" : 0,
"epi_value" : -5,
"origins_from_origins_field" : [
"en:unknown"
],
"transportation_scores" : {
"ad" : 0,
"al" : 0,
"at" : 0,
"ax" : 0,
"ba" : 0,
"be" : 0,
"bg" : 0,
"ch" : 0,
"cy" : 0,
"cz" : 0,
"de" : 0,
"dk" : 0,
"dz" : 0,
"ee" : 0,
"eg" : 0,
"es" : 0,
"fi" : 0,
"fo" : 0,
"fr" : 0,
"gg" : 0,
"gi" : 0,
"gr" : 0,
"hr" : 0,
"hu" : 0,
"ie" : 0,
"il" : 0,
"im" : 0,
"is" : 0,
"it" : 0,
"je" : 0,
"lb" : 0,
"li" : 0,
"lt" : 0,
"lu" : 0,
"lv" : 0,
"ly" : 0,
"ma" : 0,
"mc" : 0,
"md" : 0,
"me" : 0,
"mk" : 0,
"mt" : 0,
"nl" : 0,
"no" : 0,
"pl" : 0,
"ps" : 0,
"pt" : 0,
"ro" : 0,
"rs" : 0,
"se" : 0,
"si" : 0,
"sj" : 0,
"sk" : 0,
"sm" : 0,
"sy" : 0,
"tn" : 0,
"tr" : 0,
"ua" : 0,
"uk" : 0,
"us" : 0,
"va" : 0,
"world" : 0,
"xk" : 0
},
"transportation_values" : {
"ad" : 0,
"al" : 0,
"at" : 0,
"ax" : 0,
"ba" : 0,
"be" : 0,
"bg" : 0,
"ch" : 0,
"cy" : 0,
"cz" : 0,
"de" : 0,
"dk" : 0,
"dz" : 0,
"ee" : 0,
"eg" : 0,
"es" : 0,
"fi" : 0,
"fo" : 0,
"fr" : 0,
"gg" : 0,
"gi" : 0,
"gr" : 0,
"hr" : 0,
"hu" : 0,
"ie" : 0,
"il" : 0,
"im" : 0,
"is" : 0,
"it" : 0,
"je" : 0,
"lb" : 0,
"li" : 0,
"lt" : 0,
"lu" : 0,
"lv" : 0,
"ly" : 0,
"ma" : 0,
"mc" : 0,
"md" : 0,
"me" : 0,
"mk" : 0,
"mt" : 0,
"nl" : 0,
"no" : 0,
"pl" : 0,
"ps" : 0,
"pt" : 0,
"ro" : 0,
"rs" : 0,
"se" : 0,
"si" : 0,
"sj" : 0,
"sk" : 0,
"sm" : 0,
"sy" : 0,
"tn" : 0,
"tr" : 0,
"ua" : 0,
"uk" : 0,
"us" : 0,
"va" : 0,
"world" : 0,
"xk" : 0
},
"values" : {
"ad" : -5,
"al" : -5,
"at" : -5,
"ax" : -5,
"ba" : -5,
"be" : -5,
"bg" : -5,
"ch" : -5,
"cy" : -5,
"cz" : -5,
"de" : -5,
"dk" : -5,
"dz" : -5,
"ee" : -5,
"eg" : -5,
"es" : -5,
"fi" : -5,
"fo" : -5,
"fr" : -5,
"gg" : -5,
"gi" : -5,
"gr" : -5,
"hr" : -5,
"hu" : -5,
"ie" : -5,
"il" : -5,
"im" : -5,
"is" : -5,
"it" : -5,
"je" : -5,
"lb" : -5,
"li" : -5,
"lt" : -5,
"lu" : -5,
"lv" : -5,
"ly" : -5,
"ma" : -5,
"mc" : -5,
"md" : -5,
"me" : -5,
"mk" : -5,
"mt" : -5,
"nl" : -5,
"no" : -5,
"pl" : -5,
"ps" : -5,
"pt" : -5,
"ro" : -5,
"rs" : -5,
"se" : -5,
"si" : -5,
"sj" : -5,
"sk" : -5,
"sm" : -5,
"sy" : -5,
"tn" : -5,
"tr" : -5,
"ua" : -5,
"uk" : -5,
"us" : -5,
"va" : -5,
"world" : -5,
"xk" : -5
},
"warning" : "origins_are_100_percent_unknown"
},
"packaging" : {
"non_recyclable_and_non_biodegradable_materials" : 1,
"value" : -15,
"warning" : "packaging_data_missing"
},
"production_system" : {
"labels" : [],
"value" : 0,
"warning" : "no_label"
},
"threatened_species" : {}
},
"ecoscore_not_applicable_for_category" : "en:sodas",
"missing" : {
"labels" : 1,
"origins" : 1,
"packagings" : 1
},
"missing_key_data" : 1,
"status" : "unknown"
},
"ecoscore_grade" : "not-applicable",
Expand Down
Loading

0 comments on commit 2be152e

Please sign in to comment.