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

Implements the Jelinek-Mercer smoothed ranking model. More...

#include <jelinek_mercer.h>

Inheritance diagram for meta::index::jelinek_mercer:
meta::index::language_model_ranker meta::index::ranking_function meta::index::ranker

Public Member Functions

 jelinek_mercer (float lambda=default_lambda)
 
 jelinek_mercer (std::istream &in)
 Loads a jelinek_mercer ranker from a stream. More...
 
void save (std::ostream &out) const override
 Saves the ranker to a stream. More...
 
float smoothed_prob (const score_data &sd) const override
 Calculates the smoothed probability of a term. More...
 
float doc_constant (const score_data &sd) const override
 A document-dependent constant. More...
 
- Public Member Functions inherited from meta::index::language_model_ranker
float score_one (const score_data &sd) override
 
float initial_score (const score_data &sd) const override
 Computes the constant contribution to the score of a particular document. More...
 
virtual ~language_model_ranker ()=default
 Default destructor.
 
- Public Member Functions inherited from meta::index::ranking_function
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 = "jelinek-mercer"
 The identifier for this ranker.
 
static const constexpr float default_lambda = 0.7f
 Default value of lambda.
 
- Static Public Attributes inherited from meta::index::language_model_ranker
static const util::string_view id = "language-model"
 The identifier for this ranker.
 

Private Attributes

const float lambda_
 the JM parameter
 

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

Implements the Jelinek-Mercer smoothed ranking model.

This smoothing method can be viewed as a linear interpolation between the query term probablity and the collection term probability. The model parameter lambda is the weighting of this interpolation.

Required config parameters:

[ranker]
method = "jelinek-mercer"

Optional config parameters:

lambda = 0.7

Constructor & Destructor Documentation

§ jelinek_mercer() [1/2]

meta::index::jelinek_mercer::jelinek_mercer ( float  lambda = default_lambda)
Parameters
lambda

§ jelinek_mercer() [2/2]

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

Loads a jelinek_mercer ranker from a stream.

Parameters
inThe stream to read from

Member Function Documentation

§ save()

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

Saves the ranker to a stream.

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

Implements meta::index::ranker.

§ smoothed_prob()

float meta::index::jelinek_mercer::smoothed_prob ( const score_data sd) const
overridevirtual

Calculates the smoothed probability of a term.

Parameters
sd

Implements meta::index::language_model_ranker.

§ doc_constant()

float meta::index::jelinek_mercer::doc_constant ( const score_data sd) const
overridevirtual

A document-dependent constant.

Parameters
sd

Implements meta::index::language_model_ranker.


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