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: use prepared nutrition values to compute nutriscore of cocoa and chocolate powders #6552

Merged
merged 3 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lib/ProductOpener/Food.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ sub compute_nutrition_score($) {
# unless we have nutrition data for the prepared product
# same for en:chocolate-powders, en:dessert-mixes and en:flavoured-syrups

foreach my $category_tag ("en:dried-products-to-be-rehydrated", "en:chocolate-powders", "en:dessert-mixes", "en:flavoured-syrups", "en:instant-beverages") {
foreach my $category_tag ("en:dried-products-to-be-rehydrated", "en:cocoa-and-chocolate-powders", "en:dessert-mixes", "en:flavoured-syrups", "en:instant-beverages") {

if (has_tag($product_ref, "categories", $category_tag)) {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"categories" : "cocoa and chocolate powders",
"categories_hierarchy" : [
"en:cocoa-and-its-products",
"en:cocoa-and-chocolate-powders"
],
"categories_lc" : "en",
"categories_properties" : {
"agribalyse_proxy_food_code:en" : "18167"
},
"categories_properties_tags" : [
"all-products",
"categories-known",
"agribalyse-food-code-unknown",
"agribalyse-proxy-food-code-18167",
"agribalyse-proxy-food-code-known",
"ciqual-food-code-unknown",
"agribalyse-known",
"agribalyse-18167"
],
"categories_tags" : [
"en:cocoa-and-its-products",
"en:cocoa-and-chocolate-powders"
],
"food_groups_tags" : [],
"lc" : "en",
"misc_tags" : [
"en:nutrition-grade-computed-for-prepared-product",
"en:nutrition-no-fruits-vegetables-nuts",
"en:nutrition-no-fiber-or-fruits-vegetables-nuts",
"en:nutriscore-computed"
],
"nutriments" : {
"energy_prepared_100g" : 287,
"fat_prepared_100g" : 0,
"fiber_prepared_100g" : 1.9,
"nutrition-score-fr" : -1,
"nutrition-score-fr_100g" : -1,
"proteins_prepared_100g" : 3.8,
"saturated-fat_prepared_100g" : 1.1,
"sodium_prepared_100g" : 0.045,
"sugars_prepared_100g" : 6.3
},
"nutriscore_data" : {
"energy" : 287,
"energy_points" : 0,
"energy_value" : 287,
"fiber" : 1.9,
"fiber_points" : 1,
"fiber_value" : 1.9,
"fruits_vegetables_nuts_colza_walnut_olive_oils" : 0,
"fruits_vegetables_nuts_colza_walnut_olive_oils_points" : 0,
"fruits_vegetables_nuts_colza_walnut_olive_oils_value" : 0,
"grade" : "a",
"is_beverage" : 0,
"is_cheese" : 0,
"is_fat" : 0,
"is_water" : 0,
"negative_points" : 2,
"positive_points" : 3,
"proteins" : 3.8,
"proteins_points" : 2,
"proteins_value" : 3.8,
"saturated_fat" : 1.1,
"saturated_fat_points" : 1,
"saturated_fat_ratio" : 100,
"saturated_fat_ratio_points" : 10,
"saturated_fat_ratio_value" : 100,
"saturated_fat_value" : 1.1,
"score" : -1,
"sodium" : 45,
"sodium_points" : 0,
"sodium_value" : 45,
"sugars" : 6.3,
"sugars_points" : 1,
"sugars_value" : 6.3
},
"nutriscore_grade" : "a",
"nutriscore_score" : -1,
"nutriscore_score_opposite" : 1,
"nutrition_grade_fr" : "a",
"nutrition_grades" : "a",
"nutrition_grades_tags" : [
"a"
],
"nutrition_score_beverage" : 0,
"nutrition_score_debug" : "using prepared product data for category en:cocoa-and-chocolate-powders",
"nutrition_score_warning_no_fruits_vegetables_nuts" : 1,
"pnns_groups_1" : "unknown",
"pnns_groups_1_tags" : [
"unknown",
"missing-association"
],
"pnns_groups_2" : "unknown",
"pnns_groups_2_tags" : [
"unknown",
"missing-association"
]
}
2 changes: 2 additions & 0 deletions t/nutriscore.t
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ my @tests = (
["flavored-spring-water-no-nutrition", { lc=>"en", categories=>"flavoured spring water", nutriments=>{}}],
["flavored-spring-with-nutrition", { lc=>"en", categories=>"flavoured spring water", nutriments=>{energy_100g=>378, fat_100g=>0, "saturated-fat_100g"=>0, sugars_100g=>3, sodium_100g=>0, fiber_100g=>0, proteins_100g=>0}}],

# Cocoa and chocolate powders
["cocoa-and-chocolate-powders", { lc => "en", "categories" => "cocoa and chocolate powders", nutriments=>{energy_prepared_100g=>287, fat_prepared_100g=>0, "saturated-fat_prepared_100g"=>1.1, sugars_prepared_100g=>6.3, sodium_prepared_100g=>0.045, fiber_prepared_100g=>1.9, proteins_prepared_100g=>3.8}}],

);

Expand Down
5 changes: 5 additions & 0 deletions taxonomies/categories.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7504,6 +7504,7 @@ ciqual_food_code:en:18020
ciqual_food_name:en:Tea, brewed, without sugar
ciqual_food_name:fr:Thé infusé, non sucré

# Note: en:instant-beverages is a category that changes the computation of the Nutri-Score, the canonical name should not be changed without corresponding code changes
<en:Beverages
en:Instant beverages, Instant hot beverages
ca:Begudes instantànies
Expand Down Expand Up @@ -8710,6 +8711,7 @@ de:Mischgetränk, Mix-Getränk
nl:Gemengde dranken
wikidata:en:Q3246609

# Note: en:flavoured-syrups is a category that changes the computation of the Nutri-Score, the canonical name should not be changed without corresponding code changes
<en:Beverages
<en:Syrups
en:Flavoured syrups
Expand Down Expand Up @@ -30436,6 +30438,7 @@ pt:Produtos secos, produtos desidratados, Alimentos secos, Alimentos desidratado
ru:Обезвоженные продукты
th:อาหารแห้ง

# Note: en:dried-products-to-be-rehydrated is a category that changes the computation of the Nutri-Score, the canonical name should not be changed without corresponding code changes
<en:Dried products
en:Dried products to be rehydrated
ca:Productes assecats per a ser rehidratats
Expand Down Expand Up @@ -33142,6 +33145,7 @@ nl:Rauwe cacaobonen
fr:Grué de cacao
wikidata:en:Q3118262

# Note: en:cocoa-and-chocolate-powders is a category that changes the computation of the Nutri-Score, the canonical name should not be changed without corresponding code changes
<en:Cocoa and its products
en:Cocoa and chocolate powders, chocolate and cocoa powders
ca:Pols de coco i xocolata
Expand Down Expand Up @@ -33333,6 +33337,7 @@ ciqual_food_name:fr:Gâteau (aliment moyen)
# category/cakes has 6408 products @2019-05-20
# ingredient/fr:gâteau has 59 products in french @2019-02-06

# Note: en:dessert-mixes is a category that changes the computation of the Nutri-Score, the canonical name should not be changed without corresponding code changes
<en:Cooking helpers
en:Dessert mixes, Dessert mix
de:Nachtischmischungen, Nachtischmischung
Expand Down