Skip to content

Commit

Permalink
fix: improve nutrition post-processing (#1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 authored Dec 9, 2024
1 parent 4a9323c commit 946c73b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion robotoff/prediction/nutrition_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tests/unit/prediction/test_nutrition_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 946c73b

Please sign in to comment.