feat(ingest): handle flavor variation inclusions and whole fruit zest count units in Streusel

This commit is contained in:
2026-08-17 18:25:28 -05:00
parent f6510c05ba
commit 1f783e5a41
+27 -3
View File
@@ -149,11 +149,14 @@ const KNOWN_INGREDIENT_MAP = {
"olive oil": "olive_oil",
"lemon juice": "lemon_juice",
"lemon zest": "lemon_zest",
"lemon or lime zest": "lemon_zest",
"lime zest": "lime_zest",
"lemons": "lemon",
"orange juice": "orange_juice",
"orange zest": "orange_zest",
"lime juice": "lime_juice",
"lime zest": "lime_zest",
"loose tea": "tea_loose",
"chopped nuts": "walnut",
"passion fruit puree": "passion_fruit_puree",
"raspberry puree": "raspberry_puree",
"strawberry puree": "strawberry_puree",
@@ -266,8 +269,29 @@ function cleanIngredientName(raw) {
const parenMatch = cleaned.match(/^([^(]+)\s*\(([^)]+)\)$/);
if (parenMatch) {
cleaned = parenMatch[1].trim();
notes = parenMatch[2].trim();
const baseName = parenMatch[1].trim();
const parenContent = parenMatch[2].trim();
if (/streusel/i.test(baseName)) {
if (/zest/i.test(parenContent)) {
const fruit = baseName.replace(/streusel/i, "").trim();
cleaned = `${fruit} Zest`;
notes = `Zest of whole fruit (for ${baseName})`;
} else if (/loose tea/i.test(parenContent)) {
cleaned = "Loose Tea";
notes = `For ${baseName}`;
} else if (/chopped/i.test(parenContent)) {
const nutType = baseName.replace(/streusel/i, "").trim();
cleaned = /nut/i.test(nutType) ? "Chopped Nuts" : (nutType || "Nuts");
notes = `${parenContent} (for ${baseName})`;
} else {
cleaned = baseName;
notes = parenContent;
}
} else {
cleaned = baseName;
notes = parenContent;
}
}
return { name: cleaned, notes };