Documentation
¶
Overview ¶
Package bm25 implements the Okapi BM25 ranking function.
The implementation was derived from "An Introduction to Information Retrieval, Manning et al., page 233".
Index ¶
- Variables
- func Tokenize(text string) (map[string]int, error)
- type Collection
- func (c *Collection) AddDocument(d Document) error
- func (c *Collection) GobDecode(data []byte) error
- func (c *Collection) GobEncode() ([]byte, error)
- func (c *Collection) Save(f string) error
- func (c *Collection) Score(q string, n int) ([]*ScoredDocument, error)
- func (c *Collection) SetParallel(p int) error
- func (c *Collection) SetTokenizer(t Tokenizer)
- type Document
- type ScoredDocument
- type TextDocument
- type Tokenizer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidN = errors.New("n must be > 0") ErrInvalidQ = errors.New("query must be non-zero length") ErrInvalidParallel = errors.New("number of threads must be >= 0") )
View Source
var ErrNilTokenizer = errors.New("nil tokenizer")
Functions ¶
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
func Load ¶
func Load(f string) (*Collection, error)
func (*Collection) AddDocument ¶
func (c *Collection) AddDocument(d Document) error
func (*Collection) GobDecode ¶
func (c *Collection) GobDecode(data []byte) error
func (*Collection) GobEncode ¶
func (c *Collection) GobEncode() ([]byte, error)
func (*Collection) Save ¶
func (c *Collection) Save(f string) error
func (*Collection) Score ¶
func (c *Collection) Score(q string, n int) ([]*ScoredDocument, error)
func (*Collection) SetParallel ¶
func (c *Collection) SetParallel(p int) error
func (*Collection) SetTokenizer ¶
func (c *Collection) SetTokenizer(t Tokenizer)
type ScoredDocument ¶
type TextDocument ¶
type TextDocument struct {
// contains filtered or unexported fields
}
func NewTextDocument ¶
func NewTextDocument(text string) *TextDocument
func (*TextDocument) GobDecode ¶
func (t *TextDocument) GobDecode(data []byte) error
func (*TextDocument) GobEncode ¶
func (t *TextDocument) GobEncode() ([]byte, error)
func (*TextDocument) Text ¶
func (t *TextDocument) Text() string
Click to show internal directories.
Click to hide internal directories.