feat: kitchen screen, scan dedup, gemini-3.5-flash-lite, seed grapes/beetroot/pea shoots

This commit is contained in:
Sven (AAMOS AI)
2026-08-16 20:13:49 +07:00
parent d098bf705e
commit c0a15bb1b5
20 changed files with 295 additions and 48 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ async function main() {
],
imageQualityIssues: [],
},
modelVersion: "gemini-2.5-flash",
modelVersion: "gemini-3.5-flash-lite",
promptVersion: "gemini-fridge-v1",
latencyMs: 1234,
costUsd: 0.0001,
+21 -8
View File
@@ -301,19 +301,32 @@ function findBestCanonicalMatch(
return best.item;
}
function fold(s: string): string {
// Vik bort accenter (crème -> creme) OCH å/ä/ö -> a/a/o så att plural-vokalskifte
// (morot <-> morötter) och lånord (crème fraîche) matchar konsekvent.
return s.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
}
function scoreMatch(query: string, item: CanonicalIndex): number {
const candidates = [
item.nameSv.toLowerCase(),
item.nameEn.toLowerCase(),
...item.aliases.map((a) => a.toLowerCase()),
];
const q = fold(query);
const candidates = [item.nameSv, item.nameEn, ...item.aliases].map(fold);
let max = 0;
const queryTokens = tokenize(query);
const queryTokens = tokenize(q);
for (const cand of candidates) {
if (cand === query) return 1;
if (cand.includes(query) || query.includes(cand)) max = Math.max(max, 0.85);
if (cand === q) return 1;
if (cand.includes(q) || q.includes(cand)) {
max = Math.max(max, 0.85);
continue;
}
// Delad prefix (vindruva <-> vindruvor): stark signal utan token-exakthet.
const shorter = q.length <= cand.length ? q : cand;
const longer = q.length <= cand.length ? cand : q;
let p = 0;
while (p < shorter.length && shorter[p] === longer[p]) p++;
if (p >= 5 && p / shorter.length >= 0.7) max = Math.max(max, 0.7);
const candTokens = tokenize(cand);
const intersection = queryTokens.filter((t) => candTokens.includes(t));