fix(reco): fria sökord + mjuk-filter så råvaru-sökning (kyckling) ger rätt recept (MIKRO 60)
CI / Typecheck, test & build (push) Failing after 42s

This commit is contained in:
Sven (AAMOS AI)
2026-08-14 20:28:56 +07:00
parent 83dd0bb215
commit 33c72ddacd
2 changed files with 47 additions and 2 deletions
+31 -1
View File
@@ -4,6 +4,7 @@ export interface ParsedCraving {
tags: string[];
cuisine?: Cuisine | undefined;
maxKcal?: number | undefined;
keywords: string[];
}
/**
@@ -66,5 +67,34 @@ export function parseCraving(text: string): ParsedCraving {
const kcalMatch = lower.match(/under\s+(\d{2,4})\s*(?:kcal|kalorier)/);
if (kcalMatch?.[1]) maxKcal = Number(kcalMatch[1]);
return { tags, cuisine, maxKcal };
const STOPWORDS = new Set([
"jag",
"är",
"sugen",
"på",
"vill",
"ha",
"något",
"lite",
"och",
"med",
"gärna",
"känner",
"för",
"mig",
"idag",
"ikväll",
"kväll",
"mat",
"äta",
"laga",
"göra",
"en",
"ett",
]);
const keywords = lower
.split(/[^a-zåäö0-9]+/)
.filter((w) => w.length >= 3 && !STOPWORDS.has(w));
return { tags, cuisine, maxKcal, keywords };
}