ModErn Text Analysis
META Enumerates Textual Applications
|
A ranker scores a query against all the documents in an inverted index, returning a list of documents sorted by relevance. More...
#include <ranker.h>
Public Types | |
using | filter_function_type = std::function< bool(doc_id did)> |
Public Member Functions | |
template<class ForwardIterator , class Function = bool (*)(doc_id)> | |
std::vector< search_result > | score (inverted_index &idx, ForwardIterator begin, ForwardIterator end, uint64_t num_results=10, Function &&filter=passthrough) |
std::vector< search_result > | score (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. | |
virtual void | save (std::ostream &out) const =0 |
Saves the ranker to a stream. More... | |
virtual std::vector< search_result > | rank (ranker_context &ctx, uint64_t num_results, const filter_function_type &filter)=0 |
Scores a query using a document-at-a-time strategy. More... | |
Static Public Member Functions | |
static bool | passthrough (doc_id) |
A ranker scores a query against all the documents in an inverted index, returning a list of documents sorted by relevance.
|
inline |
idx | The index this ranker is operating on |
begin | A forward iterator to the beginning of the term weights (pairs of std::string and a weight) |
end | A forward iterator to the end of the above range |
num_results | The number of results to return in the vector |
filter | A filtering function to apply to each doc_id; returns true if the document should be included in results |
std::vector< search_result > meta::index::ranker::score | ( | inverted_index & | idx, |
const corpus::document & | query, | ||
uint64_t | num_results = 10 , |
||
const filter_function_type & | filter = [](doc_id) { return true; } |
||
) |
idx | The index this ranker is operating on |
query | The current query |
num_results | The number of results to return in the vector |
filter | A filtering function to apply to each doc_id; returns true if the document should be included in results |
|
pure virtual |
Saves the ranker to a stream.
This should save the ranker's id, followed by any parameters needed for reconstruction.
Implemented in meta::index::rocchio, meta::index::kl_divergence_prf, meta::index::okapi_bm25, meta::index::pivoted_length, meta::index::jelinek_mercer, meta::index::absolute_discount, and meta::index::dirichlet_prior.
|
pure virtual |
Scores a query using a document-at-a-time strategy.
You should not override this unless you desire a completely different ranking strategy than document-at-a-time, which might be the case if you are implementing a new pseudo-relevance feedback method.
ctx | The ranker_context holding the postings lists |
num_results | The number of search results to return |
filter | The filter function to be used |
Implemented in meta::index::ranking_function, meta::index::rocchio, and meta::index::kl_divergence_prf.