pub fn score(
query_terms: &[String],
term_freq: &HashMap<String, u32>,
doc_len: u32,
avg_doc_len: f64,
n_docs_with: &HashMap<String, u32>,
total_docs: u32,
params: &Bm25Params,
) -> f64Expand description
Compute the BM25 score for a single (document, query) pair.
query_termsis the pre-tokenized query. Duplicate tokens are summed naturally — if the user typed"rust rust db", therustcontribution gets counted twice, matching the standard formulation.term_freqmaps each unique term in the document to its frequency within that document. The caller can build this fromsuper::tokenizer::tokenizeoutput.n_docs_withis the corpus statistic — for each term, how many distinct documents contain it. Only entries for query terms are read; extra entries are ignored.- Returns
0.0for the empty query, the empty corpus (total_docs == 0), or a document whose terms don’t intersect the query.