feat: kitchen screen, scan dedup, gemini-3.5-flash-lite, seed grapes/beetroot/pea shoots
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -71,7 +71,7 @@ describe("BUILD_TRAINING_SAMPLE banks locally", () => {
|
||||
corrected: { displayName: "Mellanmjölk", quantity: 1, unit: "LITER" },
|
||||
},
|
||||
imageS3Key: "fridge-scans/train.jpg",
|
||||
modelVersion: "gemini-2.5-flash",
|
||||
modelVersion: "gemini-3.5-flash-lite",
|
||||
promptVersion: "gemini-fridge-v1",
|
||||
consentSnapshot: { anonymized_improvement: "granted", image_training: "granted" },
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user