From 1f783e5a415c211b05a84905e169021ad82b9ae0 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Mon, 17 Aug 2026 18:25:28 -0500 Subject: [PATCH] feat(ingest): handle flavor variation inclusions and whole fruit zest count units in Streusel --- scripts/ingest-docling-book.mjs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/scripts/ingest-docling-book.mjs b/scripts/ingest-docling-book.mjs index f0ce23e..bde9672 100644 --- a/scripts/ingest-docling-book.mjs +++ b/scripts/ingest-docling-book.mjs @@ -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 };