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

energy-value-in-kcal-does-not-match-value-in-kj: false positive for low values #7811

Closed
CharlesNepote opened this issue Dec 7, 2022 · 2 comments · Fixed by #7864
Closed
Assignees
Labels
🐛 bug This is a bug, not a feature request. 🧽 Data quality https://wiki.openfoodfacts.org/Quality

Comments

@CharlesNepote
Copy link
Member

CharlesNepote commented Dec 7, 2022

Describe the bug

https://wiki.openfoodfacts.org/Data_quality_issues_which_can%27t_be_fixed#When_energy_values_are_low_.281-10_Kcal.29

When energy values are low (1-10 Kcal?), there are often matching issues between the energy in Kcal and KJ. This often because producers are rounding the values.

Eg. https://world.openfoodfacts.org/product/3502110008459: In this example, 1 Kcal (rounded) => 6 KJ. Because 6 / 4.2 = 1.428, the producer is probably rounding 1.42 to 1.

see also:

Expected behavior

This should be a warning and not an error.

@CharlesNepote CharlesNepote added the 🐛 bug This is a bug, not a feature request. label Dec 7, 2022
@teolemon teolemon added the 🧽 Data quality https://wiki.openfoodfacts.org/Quality label Dec 11, 2022
@alexgarel
Copy link
Member

@CharlesNepote
Copy link
Member Author

CharlesNepote commented Dec 20, 2022

As of 2022-12-20, there are 203 products with less than 2 Kcal and less than 6.5 KJ which provide the error.

There are also many products with a serving size under 2g which are probably concerned but not detected yet because the energy in Kcal is not yet filed.

I made a spreadsheet to understand the impact of rounding low values. We can see that the issue occurs when Kcal is equal to 2 or below.

The place to change our threshold is there: https://github.com/openfoodfacts/openfoodfacts-server/blob/main/lib/ProductOpener/DataQualityFood.pm#L689

# check energy in kcal is ~ 4.2 energy in kj
if (
		(
			$product_ref->{nutriments}{"energy-kj_value"}
-			< 3.7 * $product_ref->{nutriments}{"energy-kcal_value"} - 1
+			< 3.7 * $product_ref->{nutriments}{"energy-kcal_value"} - 2
		)
		or ($product_ref->{nutriments}{"energy-kj_value"}
-			> 4.7 * $product_ref->{nutriments}{"energy-kcal_value"} + 1)
+			> 4.7 * $product_ref->{nutriments}{"energy-kcal_value"} + 2)
		)
	{
		push @{$product_ref->{data_quality_errors_tags}}, "en:energy-value-in-kcal-does-not-match-value-in-kj";
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug This is a bug, not a feature request. 🧽 Data quality https://wiki.openfoodfacts.org/Quality
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants