Skip to content
1 min read · 104 words

Function: relevanceToQuery()

ts
function relevanceToQuery(
  text: string,
  queryTokens: ReadonlySet<string>,
): number;

Defined in: src/batteries/context/thrift/relevance.ts:135

What fraction of the QUERY's content words appear in text — the relevance of a prior turn to the CURRENT query (not the reverse: a turn need not share all its own content, only enough of the query's).

Parameters

ParameterTypeDescription
textstringThe candidate turn's combined text (see HistoryTurn.qa).
queryTokensReadonlySet<string>The current query's content-word set, from contentTokens.

Returns

number

A fraction in [0, 1]; 0 when queryTokens is empty (an empty query matches nothing).