22 #include "../common/type.hpp"
24 #include "jubatus/util/concurrent/lock.h"
26 using jubatus::util::concurrent::scoped_lock;
30 namespace fv_converter {
35 bool operator()(
const std::pair<std::string, float>& p) {
51 : weights_(w), version_(v) {
77 for (common::sfv_t::iterator it = fv.begin(); it != fv.end(); ++it) {
79 it->second =
static_cast<float>(it->second * global_weight);
81 fv.erase(remove_if(fv.begin(), fv.end(), is_zero()), fv.end());
85 size_t p = key.find_last_of(
'/');
86 if (p == std::string::npos) {
89 std::string type = key.substr(p + 1);
92 }
else if (type ==
"idf") {
95 return std::log((doc_count + 1) / (doc_freq + 1));
96 }
else if (type ==
"weight") {
97 p = key.find_last_of(
'#');
98 if (p == std::string::npos) {
util::concurrent::mutex mutex_
size_t get_document_frequency(const std::string &key) const
double get_user_weight(const std::string &key) const
void get_weight(common::sfv_t &fv) const
void merge(const keyword_weights &w)
versioned_weight_diff & merge(const versioned_weight_diff &target)
void update_document_frequency(const common::sfv_t &fv)
void add_weight(const std::string &key, float weight)
keyword_weights diff_weights_
double get_global_weight(const std::string &key) const
fv_converter::keyword_weights weights_
void add_weight(const std::string &key, float weight)
void update_weight(const common::sfv_t &fv)
std::vector< std::pair< std::string, float > > sfv_t
storage::version version_
uint64_t get_document_count() const