ModErn Text Analysis
META Enumerates Textual Applications
Public Types | Public Member Functions | Static Public Member Functions | List of all members
meta::index::ranker Class Referenceabstract

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>

Inheritance diagram for meta::index::ranker:
meta::index::kl_divergence_prf meta::index::ranking_function meta::index::rocchio meta::index::language_model_ranker meta::index::okapi_bm25 meta::index::pivoted_length meta::index::absolute_discount meta::index::dirichlet_prior meta::index::jelinek_mercer

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_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.
 
virtual void save (std::ostream &out) const =0
 Saves the ranker to a stream. More...
 
virtual std::vector< search_resultrank (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)
 

Detailed Description

A ranker scores a query against all the documents in an inverted index, returning a list of documents sorted by relevance.

Member Function Documentation

§ score() [1/2]

template<class ForwardIterator , class Function = bool (*)(doc_id)>
std::vector<search_result> meta::index::ranker::score ( inverted_index idx,
ForwardIterator  begin,
ForwardIterator  end,
uint64_t  num_results = 10,
Function &&  filter = passthrough 
)
inline
Parameters
idxThe index this ranker is operating on
beginA forward iterator to the beginning of the term weights (pairs of std::string and a weight)
endA forward iterator to the end of the above range
num_resultsThe number of results to return in the vector
filterA filtering function to apply to each doc_id; returns true if the document should be included in results

§ score() [2/2]

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; } 
)
Parameters
idxThe index this ranker is operating on
queryThe current query
num_resultsThe number of results to return in the vector
filterA filtering function to apply to each doc_id; returns true if the document should be included in results

§ save()

virtual void meta::index::ranker::save ( std::ostream &  out) const
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.

§ rank()

virtual std::vector<search_result> meta::index::ranker::rank ( ranker_context ctx,
uint64_t  num_results,
const filter_function_type &  filter 
)
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.

Parameters
ctxThe ranker_context holding the postings lists
num_resultsThe number of search results to return
filterThe filter function to be used

Implemented in meta::index::ranking_function, meta::index::rocchio, and meta::index::kl_divergence_prf.


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