-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Automatically set sugars or saturated-fat to 0 when carbohydrates or fat is 0 #4561
Comments
As of 2022-10-25, more than 44,000 products are in this case, representing 1.7% of all products. Also more than 35K of them (1.38% of total number of products) do have a category, which means Nutri-Score could probably be calculated for those. |
A question related to this issue is the interest to know if the 0 is written on the product or computed. I find interesting to know:
Some other nutrient values could be computed based on some rules. For example, if a product is virgin olive oil and he does not have some nutrient values, the missing values could be computed/deduced from either category means or other databases such as CIQUAL, etc. |
|
@alexgarel in fact I think the safest thing would be to not set values to 0, but instead to assume they are 0 when we compute the Nutri-Score. If carbohydrates is 0 but sugars is not 0, we should not do anything I think, there's no way to know which value is correct or not. Putting "-" for sugar is not a good idea. "-" indicates that the value is not on the package. But we have no way to know that, it could just be that the value was not entered. So in short, I think we should just change Nutriscore.pm to assume sugars is 0 when we don't have a sugars value but we have a carbohydrates value. |
There are many cases where we could benefit to have a
The logic of these fields would be:
Thus, our algorithm for Nutri-Score, Eco-Score, Nova, Energy, etc. should be based on |
We could have *_computed and *_estimated indeed. It might be useful to think a bit more about it. The quick and dirty solution would be to suffix the fields and add them to the nutriments hash, but it's already very messy.Maybe we could put a bit more structure. e.g. nutrients->{as_sold|prepared}{per 100g|per serving}{listed|computed|estimated}{carbohydrates} |
@alexgarel As a short term solution, I think we could create a Nutrients.pm module (to keep Food.pm from growing) with a compute_nutrients($nutrients_ref) function that returns computed nutrients (with things like sugars and saturated fat set to 0). Then we call it when we create the input to compute the Nutriscore, to check nutrients data quality etc. Then we can take a bit more time to see if we should also store the result in the product data, and how to do it. |
For the moment I decided to tweak the nutriscore_data structure. |
It's done on #7947 - waiting for reviews. |
What
e.g. https://world.openfoodfacts.org/product/8888090781045/sunflower-oil-golden-circle
Part of
The text was updated successfully, but these errors were encountered: