Documentation
¶
Overview ¶
Package bm25 implements the Okapi BM25 ranking function for text retrieval.
Index ¶
- type Scorer
- func (s *Scorer) AddDocument(id int64, text string)
- func (s *Scorer) AddDocuments(ids []int64, texts []string)
- func (s *Scorer) DocCount() int
- func (s *Scorer) HasDocument(id int64) bool
- func (s *Scorer) Score(query string) map[int64]float32
- func (s *Scorer) ScoreDocIDs(query string, ids []int64) []float32
- func (s *Scorer) TopK(query string, k int) ([]int64, []float32)
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 ¶
NewScorerWithParams creates a BM25 scorer with custom parameters.
func (*Scorer) AddDocument ¶
AddDocument adds a document to the BM25 index.
func (*Scorer) AddDocuments ¶
AddDocuments adds multiple documents at once.
func (*Scorer) HasDocument ¶
HasDocument returns true if the document is already indexed.
func (*Scorer) Score ¶
Score computes BM25 scores for the query against all indexed documents. Returns a map from document ID to score.
func (*Scorer) ScoreDocIDs ¶
ScoreDocIDs computes BM25 scores for the query against specific document IDs.
Click to show internal directories.
Click to hide internal directories.