ModErn Text Analysis
META Enumerates Textual Applications
kl_divergence_prf.h
Go to the documentation of this file.
1 
10 #ifndef META_INDEX_KL_DIVERGENCE_PRF_H_
11 #define META_INDEX_KL_DIVERGENCE_PRF_H_
12 
15 
16 namespace meta
17 {
18 namespace index
19 {
20 
45 class kl_divergence_prf : public ranker
46 {
47  public:
49  const static util::string_view id;
50 
52  const static constexpr float default_alpha = 0.5;
53 
55  const static constexpr float default_lambda = 0.5;
56 
58  const static constexpr uint64_t default_k = 10;
59 
64  const static constexpr uint64_t default_max_terms = 50;
65 
66  kl_divergence_prf(std::shared_ptr<forward_index> fwd);
67 
68  kl_divergence_prf(std::shared_ptr<forward_index> fwd,
69  std::unique_ptr<language_model_ranker>&& initial_ranker,
70  float alpha = default_alpha,
71  float lambda = default_lambda, uint64_t k = default_k,
72  uint64_t max_terms = default_max_terms);
73 
74  kl_divergence_prf(std::istream& in);
75 
76  void save(std::ostream& out) const override;
77 
78  std::vector<search_result>
79  rank(ranker_context& ctx, uint64_t num_results,
80  const filter_function_type& filter) override;
81 
82  private:
83  std::shared_ptr<forward_index> fwd_;
84  std::unique_ptr<language_model_ranker> initial_ranker_;
85  const float alpha_;
86  const float lambda_;
87  const uint64_t k_;
88  const uint64_t max_terms_;
89 };
90 
95 template <>
96 std::unique_ptr<ranker>
97 make_ranker<kl_divergence_prf>(const cpptoml::table& global,
98  const cpptoml::table& local);
99 }
100 }
101 #endif
void save(std::ostream &out) const override
Saves the ranker to a stream.
Definition: kl_divergence_prf.cpp:70
A ranker scores a query against all the documents in an inverted index, returning a list of documents...
Definition: ranker.h:159
Stores a list of postings_stream and other relevant information for performing document-at-a-time ran...
Definition: ranker.h:103
Implements the two-component mixture model for pseudo-relevance feedback in the KL-divergence retriev...
Definition: kl_divergence_prf.h:45
std::unique_ptr< ranker > make_ranker< kl_divergence_prf >(const cpptoml::table &global, const cpptoml::table &local)
Specialization of the factory method used to create kl_divergence_prf rankers.
Definition: kl_divergence_prf.cpp:134
A non-owning reference to a string.
Definition: string_view.h:51
static const constexpr float default_alpha
Default value of alpha, the query interpolation parameter.
Definition: kl_divergence_prf.h:52
std::vector< search_result > rank(ranker_context &ctx, uint64_t num_results, const filter_function_type &filter) override
Scores a query using a document-at-a-time strategy.
Definition: kl_divergence_prf.cpp:82
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
static const constexpr float default_lambda
Default value for lambda, the mixture model interpolation parameter.
Definition: kl_divergence_prf.h:55
static const constexpr uint64_t default_max_terms
Default value for max_terms, the number of feedback terms to interpolate into the query model...
Definition: kl_divergence_prf.h:64
static const util::string_view id
Identifier for this ranker.
Definition: kl_divergence_prf.h:49
static const constexpr uint64_t default_k
Default value for k, the number of feedback documents to retrieve.
Definition: kl_divergence_prf.h:58