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

Implements Bayesian smoothing with a Dirichlet prior. More...

#include <dirichlet_prior.h>

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

Public Member Functions

 dirichlet_prior (float mu=default_mu)
 
 dirichlet_prior (std::istream &in)
 Loads a dirichlet_prior 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 = "dirichlet-prior"
 Identifier for this ranker.
 
static const constexpr float default_mu = 2000.0f
 Default value of mu.
 
- 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 mu_
 the Dirichlet prior 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 Bayesian smoothing with a Dirichlet prior.

Required config parameters:

[ranker]
method = "dirichlet-prior"

Optional config parameters:

mu = 2000.0

Constructor & Destructor Documentation

§ dirichlet_prior() [1/2]

meta::index::dirichlet_prior::dirichlet_prior ( float  mu = default_mu)
Parameters
mu

§ dirichlet_prior() [2/2]

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

Loads a dirichlet_prior ranker from a stream.

Parameters
inThe stream to read from

Member Function Documentation

§ save()

void meta::index::dirichlet_prior::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::dirichlet_prior::smoothed_prob ( const score_data sd) const
overridevirtual

Calculates the smoothed probability of a term.

Parameters
sdscore_data for the current query

Implements meta::index::language_model_ranker.

§ doc_constant()

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

A document-dependent constant.

Parameters
sdscore_data for the current query

Implements meta::index::language_model_ranker.


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