Skip to content

Commit b71979b

Browse files
feat: Update synonym mapping and adjust scoring thresholds for improved food search accuracy
1 parent 0ec4117 commit b71979b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/handlers/foodHandlers.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ import type { ParsedFoodItem } from './naturalLanguageSearchHandler';
2727

2828
// Simple synonym map to improve search hit rates for common regional terms.
2929
const SYNONYM_MAP: Record<string, string> = {
30-
curd: 'yogurt',
30+
curd: 'plain yogurt',
3131
paneer: 'cottage cheese',
32+
dahi: 'plain yogurt',
3233
};
3334

3435
// Shared list of common preparation modifiers for lightweight score tuning.
@@ -207,7 +208,7 @@ const computeFoodScore = (
207208
let modifierMatchScore = 0;
208209
for (const mod of normalizedModifiers) {
209210
if (description.includes(mod)) {
210-
modifierMatchScore += 25;
211+
modifierMatchScore += 50;
211212
}
212213
}
213214
score += modifierMatchScore;
@@ -295,7 +296,7 @@ export const processSingleFoodItem = async (
295296

296297
const rankedFoods = scoredFoods.sort((a, b) => b.internalScore - a.internalScore);
297298

298-
if (rankedFoods.length === 0 || rankedFoods[0].internalScore < 40) {
299+
if (rankedFoods.length === 0 || rankedFoods[0].internalScore < 35) {
299300
logger.warn(
300301
`No relevant ranked results for item: "${effectiveFoodName}"`,
301302
{
@@ -486,7 +487,7 @@ const getSuggestions = async (
486487

487488
const rankedFoods = scoredFoods.sort((a, b) => b.internalScore - a.internalScore);
488489

489-
if (rankedFoods.length === 0 || rankedFoods[0].internalScore < 40) {
490+
if (rankedFoods.length === 0 || rankedFoods[0].internalScore < 35) {
490491
return [];
491492
}
492493

0 commit comments

Comments
 (0)