The phrase to look for.
The product title to search within.
100 on a substring hit, otherwise 0.
substringScorer("sodium", "Sodium Chloride"); // 100
substringScorer("zinc", "Sodium Chloride"); // 0
export function substringScorer(term: string, title: string): number {
return title.toLowerCase().includes(term.toLowerCase()) ? 100 : 0;
}
Binary substring scorer: returns 100 when
termis a case-insensitive substring oftitle, else 0. Retained as a simple, deterministic scorer for ranking/tests; the leaf gate in scoreAstMatch uses per-word presence.