feat: expand ingredient-alias seed list to ~137 entries, ignore accents in name matching (v0.86.0)
Ingredient-alias matching (pantry, can-cook, auto-deduct, shopping-list generation) now covers common bilingual EN/FR ingredients across all 8 grocery categories, up from ~10 staples. Also: matching now ignores accents as well as case (NFD-normalize + strip combining marks) in both the alias resolver (lib/ingredient-match.ts) and the older name-fallback matcher (pantry-shopping-match.ts) — "café"/"Café"/"cafe" and "Épinard"/"epinard" all recognize as the same ingredient without needing every accent variant manually listed as an alias. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,10 @@ export type PantryAdjustedItem = {
|
||||
};
|
||||
|
||||
export function normalizeName(name: string): string {
|
||||
const trimmed = name.toLowerCase().trim().replace(/\s+/g, " ");
|
||||
// Accent-insensitive too ("café"/"cafe") — NFD splits an accented letter
|
||||
// into base letter + combining mark, then the marks (U+0300-U+036F) are
|
||||
// stripped.
|
||||
const trimmed = name.toLowerCase().trim().normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/\s+/g, " ");
|
||||
// Simple plural trim — strip a single trailing "s" for words longer than 3 chars.
|
||||
return trimmed.length > 3 && trimmed.endsWith("s") ? trimmed.slice(0, -1) : trimmed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user