bm25

package
v2.0.33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bm25 scores already-tokenised documents against a query with Okapi BM25. Tokenising and what counts as a document are the caller's: the corpus is exactly the documents passed in, so N and IDF follow them.

Index

Constants

View Source
const (
	K1 = 1.2
	B  = 0.75
)

Variables

This section is empty.

Functions

func Score

func Score(docs [][]string, query []string) []float64

Score returns one score per document. Query tokens are de-duplicated, and IDF(q) = ln((N − n(q) + 0.5)/(n(q) + 0.5) + 1), which never goes negative. No documents give an empty slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL