ModErn Text Analysis
META Enumerates Textual Applications
ranker.h
Go to the documentation of this file.
1 
9 #ifndef META_RANKER_H_
10 #define META_RANKER_H_
11 
12 #include <utility>
13 #include <vector>
14 
15 #include "meta.h"
16 
17 namespace meta
18 {
19 
20 namespace corpus
21 {
22 class document;
23 }
24 
25 namespace index
26 {
27 class inverted_index;
28 struct score_data;
29 }
30 }
31 
32 namespace meta
33 {
34 namespace index
35 {
36 
41 class ranker
42 {
43  public:
51  std::vector<std::pair<doc_id, double>>
53  uint64_t num_results = 10,
54  const std::function<bool(doc_id d_id)>& filter = [](doc_id) {
55  return true;
56  });
57 
63  virtual double score_one(const score_data& sd) = 0;
64 
70  virtual double initial_score(const score_data& sd) const;
71 
75  virtual ~ranker() = default;
76 
77  private:
79  std::vector<double> results_;
80 };
81 }
82 }
83 
84 #endif
Contains top-level namespace documentation for the META toolkit.
virtual ~ranker()=default
Default destructor.
The inverted_index class stores information on a corpus indexed by term_ids.
Definition: inverted_index.h:54
A ranker scores a query against all the documents in an inverted index, returning a list of documents...
Definition: ranker.h:41
std::vector< std::pair< doc_id, double > > score(inverted_index &idx, corpus::document &query, uint64_t num_results=10, const std::function< bool(doc_id d_id)> &filter=[](doc_id){return true;})
Definition: ranker.cpp:18
Represents an indexable document.
Definition: document.h:31
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
std::vector< double > results_
results per doc_id
Definition: ranker.h:79
virtual double score_one(const score_data &sd)=0
Computes the contribution to the score of a document for a matched query term.
A score_data object contains information needed to evaluate a ranking function.
Definition: score_data.h:39
virtual double initial_score(const score_data &sd) const
Computes the constant contribution to the score of a particular document.
Definition: ranker.cpp:85