Skip to content

lexicalRelevance

lexicalRelevance(content, terms): number

Defined in: packages/memory-ltm/src/lexical.ts:107

Fraction of terms that appear anywhere in content, in [0, 1].

Substring matching (not word-boundary matching) mirrors the SQL ILIKE %term% used to select the candidates, so the score cannot claim a match the query did not actually make — or miss one it did. Repeats do not increase the score: this measures coverage of the query, not term frequency.

Returns 0 for an empty term list so a caller cannot manufacture a perfect score from an empty query.

string | null | undefined

readonly string[]

number