Skip to content

Commit

Permalink
Merge pull request #5743 from openfoodfacts/gs1
Browse files Browse the repository at this point in the history
New packaging shapes for Eco-Score and GS1 imports
  • Loading branch information
stephanegigandet authored Sep 23, 2021
2 parents 15caacb + f7ed028 commit b7fc005
Show file tree
Hide file tree
Showing 10 changed files with 450 additions and 21 deletions.
17 changes: 16 additions & 1 deletion ecoscore/data/fr_packaging_shapes.csv
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ Cagette,1
Sachets individuels,1
Etui,1
Support,1
Couverts,1
Pailles,1
Capsule café,3
Couvercle,"0,2"
Couverts,"0,2"
Bouchon,"0,1"
Capsule,"0,1"
Feuille,"0,1"
Expand All @@ -28,3 +29,17 @@ Opercule,"0,1"
Bâtonnet,"0,1"
Attache,"0,1"
Vrac,0
Conteneur,1
Gobelet,1
Caisse,1
Lien,"0,1"
Moule,1
Flacon,1
Collier,"0,1"
Collerette,"0,1"
Enveloppe,"0,1"
Ficelle,"0,1"
Housse,1
Seau,1
Terrine,1
Cartouche,1
4 changes: 2 additions & 2 deletions lib/ProductOpener/Ecoscore.pm
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ sub load_ecoscore_data_packaging() {
die("Could not open ecoscore materials CSV $csv_file: $!");
}

$log->debug("ecoscore packaging_materials data", { packaging_meterials => $ecoscore_data{packaging_materials} }) if $log->is_debug();
$log->debug("ecoscore packaging_materials data", { packaging_materials => $ecoscore_data{packaging_materials} }) if $log->is_debug();

# Packaging shapes / formats

Expand Down Expand Up @@ -531,7 +531,7 @@ sub load_ecoscore_data_packaging() {
die("Could not open ecoscore shapes CSV $csv_file: $!");
}

$log->debug("ecoscore packaging_shapes data", { packaging_meterials => $ecoscore_data{packaging_shapes} }) if $log->is_debug();
$log->debug("ecoscore packaging_shapes data", { packaging_materials => $ecoscore_data{packaging_shapes} }) if $log->is_debug();
}


Expand Down
4 changes: 4 additions & 0 deletions lib/ProductOpener/GS1.pm
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ my %unknown_entries_in_gs1_maps = ();

packagingTypeCode => {
"AE" => "Aérosol",
"BA" => "Tonneau",
"BG" => "Sac",
"BK" => "Barquette",
"BO" => "Bouteille",
Expand All @@ -242,6 +243,7 @@ my %unknown_entries_in_gs1_maps = ();
"BX" => "Boite",
"CNG" => "Canette",
"CR" => "Caisse",
"CT" => "Conteneur",
"CU" => "Pot",
"EN" => "Enveloppe",
"JR" => "Bocal",
Expand All @@ -252,6 +254,7 @@ my %unknown_entries_in_gs1_maps = ();

packagingTypeCode_unused_not_taxonomized_yet => {
"AE" => "en:aerosol",
"BA" => "en:barrel",
"BG" => "en:bag",
"BK" => "en:tray",
"BO" => "en:bottle",
Expand All @@ -260,6 +263,7 @@ my %unknown_entries_in_gs1_maps = ();
"BX" => "en:box",
"CNG" => "en:can",
"CR" => "en:crate",
"CT" => "en:container",
"EN" => "en:envelope",
"JR" => "en:jar",
"PO" => "en:bag",
Expand Down
10 changes: 10 additions & 0 deletions t/ecoscore.t
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,16 @@ my @tests = (
ingredients_text=>"Wheat (France)",
labels_tags=>["fr:ab-agriculture-biologique"],
}
],

[
'packaging-fr-new-shapes',
{
lc => "fr",
categories_tags=>["en:baguettes"],
ingredients_text=>"Blé (France)",
packaging_text=>"1 caisse en carton, 1 paille, 2 couverts en métal, 1 gobelet en plastique, 1 enveloppe papier",
}
],

# Sodas: no Eco-Score
Expand Down
232 changes: 232 additions & 0 deletions t/expected_test_results/ecoscore/packaging-fr-new-shapes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
{
"categories_tags" : [
"en:baguettes"
],
"downgraded" : "non_recyclable_and_non_biodegradable_materials",
"ecoscore_data" : {
"adjustments" : {
"origins_of_ingredients" : {
"aggregated_origins" : [
{
"origin" : "en:france",
"percent" : 100
}
],
"epi_score" : 93,
"epi_value" : 4,
"origins_from_origins_field" : [
"en:unknown"
],
"transportation_score_be" : 85,
"transportation_score_ch" : 69,
"transportation_score_de" : 61,
"transportation_score_es" : 37,
"transportation_score_fr" : 100,
"transportation_score_ie" : 47,
"transportation_score_it" : 47,
"transportation_score_lu" : 82,
"transportation_score_nl" : 77,
"transportation_score_uk" : 68,
"transportation_value_be" : 13,
"transportation_value_ch" : 10,
"transportation_value_de" : 9,
"transportation_value_es" : 6,
"transportation_value_fr" : 15,
"transportation_value_ie" : 7,
"transportation_value_it" : 7,
"transportation_value_lu" : 12,
"transportation_value_nl" : 12,
"transportation_value_uk" : 10,
"value_be" : 17,
"value_ch" : 14,
"value_de" : 13,
"value_es" : 10,
"value_fr" : 19,
"value_ie" : 11,
"value_it" : 11,
"value_lu" : 16,
"value_nl" : 16,
"value_uk" : 14
},
"packaging" : {
"non_recyclable_and_non_biodegradable_materials" : 1,
"packagings" : [
{
"ecoscore_material_score" : "92",
"ecoscore_shape_ratio" : "1",
"material" : "en:cardboard",
"number" : "1",
"shape" : "en:case"
},
{
"ecoscore_material_score" : 0,
"ecoscore_shape_ratio" : "1",
"material" : "en:unknown",
"number" : "1",
"shape" : "en:straw"
},
{
"ecoscore_material_score" : 0,
"ecoscore_shape_ratio" : "1",
"material" : "en:metal",
"number" : "2",
"shape" : "en:eating-utensils"
},
{
"ecoscore_material_score" : "0",
"ecoscore_shape_ratio" : "1",
"material" : "en:plastic",
"non_recyclable_and_non_biodegradable" : "maybe",
"number" : "1",
"shape" : "en:tumbler"
},
{
"ecoscore_material_score" : "92",
"ecoscore_shape_ratio" : "0.1",
"material" : "en:paper",
"number" : "1",
"shape" : "en:envelope"
}
],
"score" : -208.8,
"value" : -15,
"warning" : "unspecified_material"
},
"production_system" : {
"labels" : [],
"value" : 0,
"warning" : "no_label"
},
"threatened_species" : {}
},
"agribalyse" : {
"agribalyse_food_code" : "7001",
"co2_agriculture" : "0.27683119",
"co2_consumption" : "0",
"co2_distribution" : "0.0064852108",
"co2_packaging" : "0.096327546",
"co2_processing" : "0.15668205",
"co2_total" : "0.66956768",
"co2_transportation" : "0.13323488",
"code" : "7001",
"dqr" : "1.95",
"ef_agriculture" : "0.060092513",
"ef_consumption" : "0",
"ef_distribution" : "0.0014414118",
"ef_packaging" : "0.020603751",
"ef_processing" : "0.035781102999999995",
"ef_total" : "0.12836245",
"ef_transportation" : "0.010443509",
"is_beverage" : 0,
"name_en" : "Bread, French bread, baguette",
"name_fr" : "Pain, baguette, courante",
"score" : 95
},
"grade" : "b",
"grade_be" : "b",
"grade_ch" : "b",
"grade_de" : "b",
"grade_es" : "b",
"grade_fr" : "b",
"grade_ie" : "b",
"grade_it" : "b",
"grade_lu" : "b",
"grade_nl" : "b",
"grade_uk" : "b",
"missing" : {
"labels" : 1,
"packagings" : 1
},
"missing_data_warning" : 1,
"score" : 80,
"score_be" : 97,
"score_ch" : 94,
"score_de" : 93,
"score_es" : 90,
"score_fr" : 99,
"score_ie" : 91,
"score_it" : 91,
"score_lu" : 96,
"score_nl" : 96,
"score_uk" : 94,
"status" : "known"
},
"ecoscore_grade" : "b",
"ecoscore_score" : 99,
"ecoscore_tags" : [
"b"
],
"ingredients" : [
{
"id" : "en:wheat",
"origins" : "en:france",
"percent_estimate" : 100,
"percent_max" : 100,
"percent_min" : 100,
"text" : "Blé",
"vegan" : "yes",
"vegetarian" : "yes"
}
],
"ingredients_analysis_tags" : [
"en:palm-oil-free",
"en:vegan",
"en:vegetarian"
],
"ingredients_hierarchy" : [
"en:wheat",
"en:cereal"
],
"ingredients_n" : 1,
"ingredients_n_tags" : [
"1",
"1-10"
],
"ingredients_original_tags" : [
"en:wheat"
],
"ingredients_percent_analysis" : 1,
"ingredients_tags" : [
"en:wheat",
"en:cereal"
],
"ingredients_text" : "Blé (France)",
"known_ingredients_n" : 2,
"lc" : "fr",
"misc_tags" : [
"en:ecoscore-extended-data-not-computed",
"en:ecoscore-missing-data-warning",
"en:ecoscore-computed"
],
"nutriments" : {
"fruits-vegetables-nuts-estimate-from-ingredients_100g" : 0
},
"packaging_text" : "1 caisse en carton, 1 paille, 2 couverts en métal, 1 gobelet en plastique, 1 enveloppe papier",
"packagings" : [
{
"material" : "en:cardboard",
"number" : "1",
"shape" : "en:case"
},
{
"number" : "1",
"shape" : "en:straw"
},
{
"material" : "en:metal",
"number" : "2",
"shape" : "en:eating-utensils"
},
{
"material" : "en:plastic",
"number" : "1",
"shape" : "en:tumbler"
},
{
"material" : "en:paper",
"number" : "1",
"shape" : "en:envelope"
}
],
"unknown_ingredients_n" : 0
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"abbreviated_product_name_fr" : "TAGLIATELLE",
"allergens" : "en:eggs, en:gluten, en:gluten",
"brands" : "PANZANI +",
"carbohydrates_100g_unit" : "g",
"carbohydrates_100g_value" : "70",
"categories_if_match_in_taxonomy" : "Pâtes/Nouilles - Non Prêt à Consommer (Longue Conservation), TAGLIATELLE QUALITE PATES FRAICHES",
"code" : "03038359005442",
"conservation_conditions_fr" : "Conservation à température ambiante au sec.",
"countries" : "en:france",
"customer_service_fr" : "Food Service, 37 bis, rue Saint Romain 69008 LYON",
"energy-kcal_100g_unit" : "kcal",
"energy-kcal_100g_value" : "356",
"energy-kj_100g_unit" : "kJ",
"energy-kj_100g_value" : "1508",
"fat_100g_unit" : "g",
"fat_100g_value" : "2.3",
"fiber_100g_unit" : "g",
"fiber_100g_value" : "3.6",
"generic_name_fr" : "Pâtes alimentaires",
"ingredients_text_fr" : "Ingrédients : Semoule de BLE dur de qualité supérieure, OEUFS. Contient du GLUTEN et des OEUFS",
"lang" : "fr",
"lc" : "fr",
"monounsaturated-fat_100g_unit" : "g",
"monounsaturated-fat_100g_value" : "0",
"net_weight" : "3.2 kg",
"org_name" : "PANZANI SA",
"packaging" : "Conteneur",
"preparation_fr" : "Plongez les pâtes dans de l'eau bouillante salée à votre convenance (1L pour 100g de pâtes) et laissez cuire le temps indiqué sur le devant du paquet.",
"product_name_fr" : "TAGLIATELLE QUALITE PATES FRAICHES",
"proteins_100g_unit" : "g",
"proteins_100g_value" : "12",
"quantity" : "3200 g",
"quantity_unit" : "g",
"quantity_value" : "3200",
"salt_100g_unit" : "g",
"salt_100g_value" : "0.07",
"saturated-fat_100g_unit" : "g",
"saturated-fat_100g_value" : "0.5",
"sodium_100g_unit" : "mcg",
"sodium_100g_value" : "28000",
"sources_fields:org-gs1:gln" : "3010383510000",
"sources_fields:org-gs1:gpcCategoryCode" : "10000242",
"sources_fields:org-gs1:gpcCategoryName" : "Pâtes/Nouilles - Non Prêt à Consommer (Longue Conservation)",
"sources_fields:org-gs1:isAllergenRelevantDataProvided" : "true",
"sources_fields:org-gs1:lastChangeDateTime" : "2021-03-10T12:25:25+01:00",
"sources_fields:org-gs1:partyName" : "PANZANI SA",
"sources_fields:org-gs1:publicationDateTime" : "2021-03-10T12:25:25+01:00",
"sugars_100g_unit" : "g",
"sugars_100g_value" : "0.3"
}
Binary file modified taxonomies/packaging_shapes.result.sto
Binary file not shown.
Loading

0 comments on commit b7fc005

Please sign in to comment.