diff --git a/robotoff/prediction/nutrition_extraction.py b/robotoff/prediction/nutrition_extraction.py index d42c82c26e..2b157aa69f 100644 --- a/robotoff/prediction/nutrition_extraction.py +++ b/robotoff/prediction/nutrition_extraction.py @@ -535,7 +535,7 @@ def match_nutrient_value( prefix = prefix.strip() value = f"{prefix} {value}" - if value == "O": + if value in ("O", "o"): # The OCR engine failed to recognize correctly "0" (zero) and uses # "O" (letter O) instead value = "0" diff --git a/tests/unit/prediction/test_nutrition_extraction.py b/tests/unit/prediction/test_nutrition_extraction.py index 98e6e16fed..b072b0c4a4 100644 --- a/tests/unit/prediction/test_nutrition_extraction.py +++ b/tests/unit/prediction/test_nutrition_extraction.py @@ -392,6 +392,7 @@ def test_aggregate_entities_multiple_entities(self): # Missing unit and value ends with '9' but not in target entity list ("25.9", "iron_100g", ("25.9", None, True)), ("O g", "salt_100g", ("0", "g", True)), + ("o mg", "sodium_100g", ("0", "mg", True)), ("O", "salt_100g", ("0", None, True)), # Missing unit and value ends with '9' or '8' ("0.19", "saturated_fat_100g", ("0.1", "g", True)),