fix: match multi-word foods when the brute parser splits off an unknown unit (#8744)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Gustaf AhlnerandClaude Opus 5.5 authored and GitHub committed 2026-10-21 18:37:31 +00:00
1 parent fb05f2da33
commit 9ca95fbb29
2 files changed
+27 -3

No files matched your search

@@ -81,6 +81,7 @@ def build_parsed_ing(food: str | None, unit: str | None) -> ParsedIngredient:
),
pytest.param("red pepper flakes", 0, "", "red pepper flakes", "", id="red pepper flakes"),
pytest.param("1 bell peppers", 1, "", "bell peppers", "", id="1 bell peppers"),
pytest.param("1 green onion", 1, "", "green onion", "", id="1 green onion"),
pytest.param("1 stalk bell peppers", 1, "Stalk", "bell peppers", "", id="1 big stalk bell peppers"),
pytest.param("a big stalk bell peppers", 0, "Stalk", "bell peppers", "", id="a big stalk bell peppers"),
pytest.param(
@@ -227,6 +228,22 @@ def test_brute_parser_confidence(
True,
id="no unit match",
),
pytest.param(
build_parsed_ing(unit="green", food="onion"),
None,
"green onion",
False,
True,
id="multi-word food split into unit and food",
),
pytest.param(
build_parsed_ing(unit="gren", food="onion"),
"gren",
"onion",
False,
True,
id="matched food not replaced by fuzzy multi-word match",
),
pytest.param(
build_parsed_ing(unit=None, food="potatoes"),
None,