ChemPal Documentation - v1.6.0
    Preparing search index...
    • Binary substring scorer: returns 100 when term is a case-insensitive substring of title, else 0. Retained as a simple, deterministic scorer for ranking/tests; the leaf gate in scoreAstMatch uses per-word presence.

      Parameters

      • term: string

        The phrase to look for.

      • title: string

        The product title to search within.

      Returns number

      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;
      }