bm25

package module
v0.0.0-...-7845765 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package bm25 implements the Okapi BM25 ranking function for text retrieval.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scorer

type Scorer struct {
	// contains filtered or unexported fields
}

Scorer implements the BM25 scoring algorithm.

func NewScorer

func NewScorer() *Scorer

NewScorer creates a new BM25 scorer with default parameters.

func NewScorerWithParams

func NewScorerWithParams(k1, b float64) *Scorer

NewScorerWithParams creates a BM25 scorer with custom parameters.

func (*Scorer) AddDocument

func (s *Scorer) AddDocument(id int64, text string)

AddDocument adds a document to the BM25 index.

func (*Scorer) AddDocuments

func (s *Scorer) AddDocuments(ids []int64, texts []string)

AddDocuments adds multiple documents at once.

func (*Scorer) DocCount

func (s *Scorer) DocCount() int

DocCount returns the number of documents in the index.

func (*Scorer) HasDocument

func (s *Scorer) HasDocument(id int64) bool

HasDocument returns true if the document is already indexed.

func (*Scorer) Score

func (s *Scorer) Score(query string) map[int64]float32

Score computes BM25 scores for the query against all indexed documents. Returns a map from document ID to score.

func (*Scorer) ScoreDocIDs

func (s *Scorer) ScoreDocIDs(query string, ids []int64) []float32

ScoreDocIDs computes BM25 scores for the query against specific document IDs.

func (*Scorer) TopK

func (s *Scorer) TopK(query string, k int) ([]int64, []float32)

TopK returns the top K document IDs sorted by BM25 score.

Jump to

Keyboard shortcuts

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