SOMHunter Core
sh::KeywordRanker Class Reference

#include <keyword-ranker.h>

Inheritance diagram for sh::KeywordRanker:
Collaboration diagram for sh::KeywordRanker:

Public Member Functions

 KeywordRanker (const Settings &config, const DatasetFrames &_dataset_frames)
 
 KeywordRanker (const KeywordRanker &)=delete
 
KeywordRankeroperator= (const KeywordRanker &)=delete
 
 KeywordRanker (KeywordRanker &&)=default
 
KeywordRankeroperator= (KeywordRanker &&)=default
 
 ~KeywordRanker () noexcept=default
 
StdVector< float > embedd_text_queries (const StdVector< KeywordId > &kws) const
 
const Keywordoperator[] (KeywordId idx) const
 Gets all string representants of this keyword. More...
 
KwSearchIds find (const std::string &search, size_t num_limit) const
 
void rank_sentence_query (const std::string &sentence_query_raw, ScoreModel &model, const PrimaryFrameFeatures &_dataset_features, size_t temporal) const
 
StdVector< float > get_text_query_feature (const std::string &query)
 
std::vector< std::string > tokenize_textual_query (const std::string &sentence_query_raw) const
 
std::vector< KeywordIddecode_keywords (const std::vector< std::string > &query) const
 
- Public Member Functions inherited from sh::EmbeddingRanker< PrimaryFrameFeatures >
virtual ~EmbeddingRanker () noexcept
 

Static Public Member Functions

static std::vector< Keywordparse_kw_classes_text_file (const std::string &filepath, const DatasetFrames &_dataset_frames)
 
static FeatureMatrix parse_float_matrix (const std::string &filepath, size_t row_dim, size_t begin_offset=0)
 Parses float matrix from a binary file that is written in row-major format and starts at begin_offset offset.k FORMAT: Matrix of 4B floats, row - major: More...
 
static FeatureVector parse_float_vector (const std::string &filepath, size_t dim, size_t begin_offset=0)
 FORMAT: Matrix of 4B floats: More...
 
static void report_results (const StdVector< std::pair< FrameId, float >> &sorted_results, const DatasetFrames &_dataset_frames, size_t num=10)
 

Private Attributes

std::vector< Keyword_keyword_ranker
 
FeatureMatrix kw_features
 
FeatureVector kw_features_bias_vec
 
FeatureMatrix kw_pca_mat
 
FeatureVector kw_pca_mean_vec
 

Additional Inherited Members

- Protected Member Functions inherited from sh::EmbeddingRanker< PrimaryFrameFeatures >
std::vector< float > inverse_score_vector (const std::vector< float > &query_vecs, const PrimaryFrameFeatures &_features) const
 
std::vector< float > inverse_score_vector (const float *query_vecs, const PrimaryFrameFeatures &_features) const
 

Constructor & Destructor Documentation

◆ KeywordRanker() [1/3]

sh::KeywordRanker::KeywordRanker ( const Settings config,
const DatasetFrames _dataset_frames 
)
inline

◆ KeywordRanker() [2/3]

sh::KeywordRanker::KeywordRanker ( const KeywordRanker )
delete

◆ KeywordRanker() [3/3]

sh::KeywordRanker::KeywordRanker ( KeywordRanker &&  )
default

◆ ~KeywordRanker()

sh::KeywordRanker::~KeywordRanker ( )
defaultnoexcept

Member Function Documentation

◆ decode_keywords()

std::vector< KeywordId > KeywordRanker::decode_keywords ( const std::vector< std::string > &  query) const
Here is the call graph for this function:

◆ embedd_text_queries()

StdVector< float > KeywordRanker::embedd_text_queries ( const StdVector< KeywordId > &  kws) const
Here is the call graph for this function:

◆ find()

KwSearchIds KeywordRanker::find ( const std::string &  search,
size_t  num_limit 
) const

◆ get_text_query_feature()

StdVector< float > KeywordRanker::get_text_query_feature ( const std::string &  query)
Here is the call graph for this function:

◆ operator=() [1/2]

KeywordRanker& sh::KeywordRanker::operator= ( const KeywordRanker )
delete

◆ operator=() [2/2]

KeywordRanker& sh::KeywordRanker::operator= ( KeywordRanker &&  )
default

◆ operator[]()

const Keyword& sh::KeywordRanker::operator[] ( KeywordId  idx) const
inline

Gets all string representants of this keyword.

◆ parse_float_matrix()

FeatureMatrix KeywordRanker::parse_float_matrix ( const std::string &  filepath,
size_t  row_dim,
size_t  begin_offset = 0 
)
static

Parses float matrix from a binary file that is written in row-major format and starts at begin_offset offset.k FORMAT: Matrix of 4B floats, row - major:

  • each line is dim_N * 4B floats
  • number of lines is number of selected frames

◆ parse_float_vector()

FeatureVector KeywordRanker::parse_float_vector ( const std::string &  filepath,
size_t  dim,
size_t  begin_offset = 0 
)
static

FORMAT: Matrix of 4B floats:

  • each line is dim * 4B floats
  • number of lines is number of selected frames

◆ parse_kw_classes_text_file()

std::vector< Keyword > KeywordRanker::parse_kw_classes_text_file ( const std::string &  filepath,
const DatasetFrames _dataset_frames 
)
static
Here is the call graph for this function:

◆ rank_sentence_query()

void KeywordRanker::rank_sentence_query ( const std::string &  sentence_query_raw,
ScoreModel model,
const PrimaryFrameFeatures _dataset_features,
size_t  temporal 
) const
Here is the call graph for this function:

◆ report_results()

void KeywordRanker::report_results ( const StdVector< std::pair< FrameId, float >> &  sorted_results,
const DatasetFrames _dataset_frames,
size_t  num = 10 
)
static

◆ tokenize_textual_query()

std::vector< std::string > KeywordRanker::tokenize_textual_query ( const std::string &  sentence_query_raw) const

Member Data Documentation

◆ _keyword_ranker

std::vector<Keyword> sh::KeywordRanker::_keyword_ranker
private

◆ kw_features

FeatureMatrix sh::KeywordRanker::kw_features
private

◆ kw_features_bias_vec

FeatureVector sh::KeywordRanker::kw_features_bias_vec
private

◆ kw_pca_mat

FeatureMatrix sh::KeywordRanker::kw_pca_mat
private

◆ kw_pca_mean_vec

FeatureVector sh::KeywordRanker::kw_pca_mean_vec
private

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