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

Feature request: add data-quality-error: insoluble/soluble fiber greater than total fiber #9729

Closed
jayaddison opened this issue Feb 1, 2024 · 3 comments
Labels
🧽 Data quality https://wiki.openfoodfacts.org/Quality ✨ Feature Features or enhancements to Open Food Facts server

Comments

@jayaddison
Copy link
Contributor

Problem

The Fiber nutritional field can have two sub-nutrient fields, Soluble fiber and Insoluble fiber. These do not appear by default during product editing, but can be added manually by the editor.

It should be an error for the total of those values to be greater than the Fiber value.

Proposed solution

Add a data-quality-error to detect this scenario and highlight it as a potential problem for data quality.

This could be similar to the existing Fructose plus glucose plus maltose plus lactose plus sucrose greater than sugars rule.

Additional context

An example product where this could be detected is: https://world.openfoodfacts.org/product/0027331032050/spinach-wrap (this may be an error on the printed nutritional label)

Code pointers

The similar sugars-total-validation rule mentioned previously is implemented here:

# sum of nutriments that compose sugar can not be greater than sugar value
if (
(defined $product_ref->{nutriments}{sugars_100g})
and (
(
(
(defined $product_ref->{nutriments}{fructose_100g}) ? $product_ref->{nutriments}{fructose_100g}
: 0
) + (
(defined $product_ref->{nutriments}{glucose_100g}) ? $product_ref->{nutriments}{glucose_100g}
: 0
) + (
(defined $product_ref->{nutriments}{maltose_100g}) ? $product_ref->{nutriments}{maltose_100g}
: 0
) + (
(defined $product_ref->{nutriments}{lactose_100g}) ? $product_ref->{nutriments}{lactose_100g}
: 0
) + (
(defined $product_ref->{nutriments}{sucrose_100g}) ? $product_ref->{nutriments}{sucrose_100g}
: 0
)
) > ($product_ref->{nutriments}{sugars_100g}) + 0.001
)
)
{
push @{$product_ref->{data_quality_errors_tags}},
"en:nutrition-fructose-plus-glucose-plus-maltose-plus-lactose-plus-sucrose-greater-than-sugars";
}

...and in the data quality taxonomy here: https://github.com/openfoodfacts/openfoodfacts-server/blob/main/taxonomies/data_quality.txt#L57-L58

Number of products impacted

Unknown - I expect a relatively small number; in my experience so far, these subnutrient fields are not included on nutrition labels frequently.

Time per product

Unknown.

Mockups

N/A

Part of

N/A

@alexgarel alexgarel added the 🧽 Data quality https://wiki.openfoodfacts.org/Quality label Feb 7, 2024
@teolemon teolemon added the ✨ Feature Features or enhancements to Open Food Facts server label Feb 8, 2024
@Payne680
Copy link
Contributor

Am currently working on this issue @stephanegigandet

@jayaddison
Copy link
Contributor Author

Thank you @Payne680! That is working in today's v2.30.0 release - I added a missing nutrient to the product, and the problem with the fiber values is displayed:

image

@Payne680
Copy link
Contributor

Payne680 commented Apr 9, 2024

You are welcome @jayaddison

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧽 Data quality https://wiki.openfoodfacts.org/Quality ✨ Feature Features or enhancements to Open Food Facts server
Projects
Development

No branches or pull requests

4 participants