ModErn Text Analysis
META Enumerates Textual Applications
dirichlet_prior.h
Go to the documentation of this file.
1 
9 #ifndef META_DIRICHLET_PRIOR_H_
10 #define META_DIRICHLET_PRIOR_H_
11 
14 
15 namespace meta
16 {
17 namespace index
18 {
19 
36 {
37  public:
39  const static util::string_view id;
40 
42  const static constexpr float default_mu = 2000.0f;
43 
47  dirichlet_prior(float mu = default_mu);
48 
53  dirichlet_prior(std::istream& in);
54 
55  void save(std::ostream& out) const override;
56 
61  float smoothed_prob(const score_data& sd) const override;
62 
67  float doc_constant(const score_data& sd) const override;
68 
69  private:
71  const float mu_;
72 };
73 
78 template <>
79 std::unique_ptr<ranker> make_ranker<dirichlet_prior>(const cpptoml::table&);
80 }
81 }
82 #endif
const float mu_
the Dirichlet prior parameter
Definition: dirichlet_prior.h:71
static const constexpr float default_mu
Default value of mu.
Definition: dirichlet_prior.h:42
float smoothed_prob(const score_data &sd) const override
Calculates the smoothed probability of a term.
Definition: dirichlet_prior.cpp:36
std::unique_ptr< ranker > make_ranker< dirichlet_prior >(const cpptoml::table &)
Specialization of the factory method used to create dirichlet_prior rankers.
Definition: dirichlet_prior.cpp:51
A non-owning reference to a string.
Definition: string_view.h:51
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retrieval, data mining, and other applications of text processing.
Definition: analyzer.h:25
float doc_constant(const score_data &sd) const override
A document-dependent constant.
Definition: dirichlet_prior.cpp:44
Scores documents according to one of three different smoothed language model scoring methods describe...
Definition: lm_ranker.h:25
Implements Bayesian smoothing with a Dirichlet prior.
Definition: dirichlet_prior.h:35
A score_data object contains information needed to evaluate a ranking function.
Definition: score_data.h:40
static const util::string_view id
Identifier for this ranker.
Definition: dirichlet_prior.h:39
void save(std::ostream &out) const override
Saves the ranker to a stream.
Definition: dirichlet_prior.cpp:29
dirichlet_prior(float mu=default_mu)
Definition: dirichlet_prior.cpp:18