<<

NAME

ProductOpener::Food - functions related to food products and nutrition

DESCRIPTION

The ProductOpener::FoodGroups module contains functions to determine a product food group. Food groups are a 3 level hierarchy of groups that are used by researchers (in particular researches from the EREN team that created the Nutri-Score).

In France, food groups are referred to as "PNNS groups" (PNNS stands for "Programme National Nutrition et Santé").

FUNCTIONS

compute_pnns_groups ( $product_ref )

Compute the PNNS groups of a product from its categories.

This function will ultimately be replaced by compute_food_groups().

For a time, we will compute both the old PNNS groups and the new food groups, so that we can compare the results.

Arguments

product reference $product_ref

Return values

compute_food_groups ( $product_ref )

Compute the food groups of a product from its categories.

Arguments

product reference $product_ref

Return values

The lowest level food group is stored in $product_ref->{food_group}

All levels food groups are stored in $product_ref->{food_groups_tags}

temporarily_change_categories_for_food_groups_computation ( $product_ref )

Food groups are derived from categories. In order to account to some subtleties (categories in OFF are manually entered and may have a broad and imprecise scope: e.g. what is a beverage?), this function has some rules to temporarily change categories, so that:

- only products that matche the precise definition of a beverage according to the Nutri-Score formula are counted as beverages (e.g. a beverage with more than 80% milk is not counted as beverage) - alcoholic beverages with less than 1% alcohol are not counted as alcoholic beverages - beverages with sweeteners / added sugar are automatically categorized as artificially sweetened / sweetened beverages

Arguments

product reference $product_ref

Return values

Categories can be added or removed in $product_ref->{categories_tags}

Original categories are saved in $product_ref->{original_categories_tags}

<<