ModErn Text Analysis
META Enumerates Textual Applications
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
meta::index::okapi_bm25 Class Reference

The Okapi BM25 scoring function. More...

#include <okapi_bm25.h>

Inheritance diagram for meta::index::okapi_bm25:
meta::index::ranking_function meta::index::ranker

Public Member Functions

 okapi_bm25 (float k1=default_k1, float b=default_b, float k3=default_k3)
 okapi_bm25 (std::istream &in)
 Loads an okapi_bm25 ranker from a stream. More...
float score_one (const score_data &sd) override
void save (std::ostream &out) const override
 Saves the ranker to a stream. More...
- Public Member Functions inherited from meta::index::ranking_function
virtual float initial_score (const score_data &sd) const
 Computes the constant contribution to the score of a particular document. More...
virtual std::vector< search_resultrank (ranker_context &ctx, uint64_t num_results, const filter_function_type &filter) override final
 Scores a query using a document-at-a-time strategy. More...
- Public Member Functions inherited from meta::index::ranker
template<class ForwardIterator , class Function = bool (*)(doc_id)>
std::vector< search_resultscore (inverted_index &idx, ForwardIterator begin, ForwardIterator end, uint64_t num_results=10, Function &&filter=passthrough)
std::vector< search_resultscore (inverted_index &idx, const corpus::document &query, uint64_t num_results=10, const filter_function_type &filter=[](doc_id) { return true;})
virtual ~ranker ()=default
 Default destructor.

Static Public Attributes

static const util::string_view id = "bm25"
 The identifier for this ranker.
static const constexpr float default_k1 = 1.2f
 Default k1, doc term smoothing.
static const constexpr float default_b = 0.75f
 Default b, length normalization.
static const constexpr float default_k3 = 500.0f
 Default k3, query term smoothing.

Private Attributes

const float k1_
 Doc term smoothing.
const float b_
 Length normalization.
const float k3_
 Query term smoothing.

Additional Inherited Members

- Public Types inherited from meta::index::ranker
using filter_function_type = std::function< bool(doc_id did)>
- Static Public Member Functions inherited from meta::index::ranker
static bool passthrough (doc_id)

Detailed Description

The Okapi BM25 scoring function.

Required config parameters:

method = "bm25"

Optional config parameters:

k1 = 1.2
b = 0.75
k3 = 500.0

Constructor & Destructor Documentation

§ okapi_bm25() [1/2]

meta::index::okapi_bm25::okapi_bm25 ( float  k1 = default_k1,
float  b = default_b,
float  k3 = default_k3 
k1Doc term smoothing
bLength normalization
k3Query term smoothing

§ okapi_bm25() [2/2]

meta::index::okapi_bm25::okapi_bm25 ( std::istream &  in)

Loads an okapi_bm25 ranker from a stream.

inThe stream to read from

Member Function Documentation

§ score_one()

float meta::index::okapi_bm25::score_one ( const score_data sd)
sdscore_data for the current query

Implements meta::index::ranking_function.

§ save()

void meta::index::okapi_bm25::save ( std::ostream &  out) const

Saves the ranker to a stream.

This should save the ranker's id, followed by any parameters needed for reconstruction.

Implements meta::index::ranker.

The documentation for this class was generated from the following files: