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

Limit percent max of some ingredients (e.g. aroma, ferments) (needed for milk estimate for Nutri-Score) #5369

Closed
Tracked by #9096 ...
stephanegigandet opened this issue Jul 13, 2021 · 3 comments · Fixed by #7639 or #7596
Assignees
Labels
✨ Feature Features or enhancements to Open Food Facts server 🥗🔍 Ingredients analysis https://wiki.openfoodfacts.org/Ingredients_Extraction_and_Analysis 🚦 Nutri-Score

Comments

@stephanegigandet
Copy link
Contributor

stephanegigandet commented Jul 13, 2021

What

We currently estimate % min and max for each ingredient in the ingredient list. And those % can be used for the Nutri-Score (e.g. to see if a product has more than 80% milk and should not be considered a beverage), for the Eco-Score etc.

For something like "Milk, ferments", we get this result:
https://world.openfoodfacts.org/cgi/test_ingredients_analysis.pl?ingredients_text=Milk%2C+ferments&type=add&action=process&submit=Envoyer

Milk -> en:milk - vegan: no - vegetarian: yes - percent_min: 50 - percent_max: 100
ferments -> en:ferment - vegan: maybe - vegetarian: maybe - percent_min: 0 - percent_max: 50

In practice, we could consider that some ingredients are never above 5% (unless they are the first and sole ingredients, like a bottle of ferments or a bottle of aroma).

And in this case, we could determine that this product is at least 95% milk, instead of at least 50% milk.

Part of

@stephanegigandet stephanegigandet added ✨ Feature Features or enhancements to Open Food Facts server 🚦Nutri-Score https://world.openfoodfacts.org/nutriscore 🥗🔍 Ingredients analysis https://wiki.openfoodfacts.org/Ingredients_Extraction_and_Analysis labels Jul 13, 2021
@stephanegigandet stephanegigandet self-assigned this Jul 13, 2021
@github-actions
Copy link
Contributor

This issue is stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the ⏰ Stale This issue hasn't seen activity in a while. You can try documenting more to unblock it. label Oct 12, 2021
@john-gom
Copy link
Contributor

I'm working on this at the moment. Proposing to add a percent_max:en property to the ingredients taxonomy.

@alexgarel alexgarel removed the ⏰ Stale This issue hasn't seen activity in a while. You can try documenting more to unblock it. label Nov 3, 2022
@john-gom
Copy link
Contributor

john-gom commented Nov 7, 2022

In order to limit the "blast radius" of this change the percent_max will not be applied in the following scenarios:

  • To sub-ingredients
  • Where the first ingredient has a percent_max defined (e.g. the product is entirely flavouring)
  • If the percent_max would be less than any later (smaller quantity) ingredients
  • If the larger ingredients have percentages specified and the percent max when added this would not allow the total to reach 100%

stephanegigandet added a commit that referenced this issue Nov 9, 2022
…7639)

* Allow a percent_max to be specified in ingredients

* Update lib/ProductOpener/Ingredients.pm

Co-authored-by: Stéphane Gigandet <stephane@openfoodfacts.org>

* Additional guard against maximum. Note test doesn't fail without this

* Make else block consistent

* Set MSYS_NO_PATHCONV for Windows and added update_tests_results make task

* Limiting scope so can't contradict stated percentages

* Catch empty ingredients and removed debugging

* Fix perltidty

* Fix for perlcritic

* Cope with multiple constrained ingredients

Co-authored-by: Stéphane Gigandet <stephane@openfoodfacts.org>
@teolemon teolemon added 🚦 Nutri-Score and removed 🚦Nutri-Score https://world.openfoodfacts.org/nutriscore labels May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature Features or enhancements to Open Food Facts server 🥗🔍 Ingredients analysis https://wiki.openfoodfacts.org/Ingredients_Extraction_and_Analysis 🚦 Nutri-Score
Projects
Status: Done
4 participants