ProductOpener::ForestFootprint - compute the forest footprint of a food product
ProductOpener::Ecoscore
is used to compute the forest footprint of a food product.
The modules implements the forest footprint computation as defined by the French NGO Envol Vert.
The computation is based on the amount of soy needed to produce the ingredients, and the risk that that soy contributed to deforestation.
Loads data needed to compute the forest footprint.
compute_forest_footprint()
computes the forest footprint of a food product,
and stores the details of the computation.
The forest footprint and computations details are stored in the product reference passed as input parameter.
Returned values:
- ecoscore_score : numeric Eco-Score value - ecoscore_grade : corresponding A to E grade - forest_footprint_data : forest footprint computation details
This function is called when we have an ingredient or a category for which we have a forest footprint. It determines the type of the footprint based on labels, origins etc. and adds a corresponding footprint to the list of footprints for the products (possibly several if the product has multiple ingredients with a footprint)
add_footprint($product_ref, $ingredient_ref, $footprints_ref, $ingredients_category_ref, { tag => ["ingredients", $ingredients_ref->{id}, $category_ingredient_id], percent_estimate => $ingredients_ref->{percent_estimate}, });
Computes the forest footprints of the ingredients.
The function is recursive and may call itself for sub-ingredients.
Used to determine the footprint type based on labels, categories, origins etc.
Data structure to which we will add the forest footprints for the ingredients specified in $ingredients_ref
Ingredients reference that may contains an ingredients structure for sub-ingredients.
The footprints are stored in $footprints_ref
Computes the forest footprints associated with the category of the product, if the product does not have ingredients (e.g. "whole chickens" category for which we may not have ingredients listed)
Used to determine the footprint type based on labels, categories, origins etc.
Data structure to which we will add the forest footprints for the ingredients specified in $ingredients_ref
The footprints are stored in $footprints_ref