jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
jubatus::core::fv_converter::datum_to_fv_converter_impl Class Reference

impl More...

Collaboration diagram for jubatus::core::fv_converter::datum_to_fv_converter_impl:
Collaboration graph

Classes

struct  binary_feature_rule
 
struct  combination_feature_rule
 
struct  num_feature_rule
 
struct  num_filter_rule
 
struct  string_feature_rule
 
struct  string_filter_rule
 

Public Member Functions

void add_weight (const std::string &key, float weight)
 
void clear_rules ()
 
void clear_weights ()
 
void convert (const datum &datum, common::sfv_t &ret_fv) const
 
void convert_and_update_weight (const datum &datum, common::sfv_t &ret_fv)
 
void convert_unweighted (const datum &datum, common::sfv_t &ret_fv) const
 
 datum_to_fv_converter_impl ()
 
void register_binary_rule (const std::string &name, jubatus::util::lang::shared_ptr< key_matcher > matcher, jubatus::util::lang::shared_ptr< binary_feature > feature_func)
 
void register_combination_rule (const std::string &name, jubatus::util::lang::shared_ptr< key_matcher > matcher_left, jubatus::util::lang::shared_ptr< key_matcher > matcher_right, jubatus::util::lang::shared_ptr< combination_feature > feature_func)
 
void register_num_filter (jubatus::util::lang::shared_ptr< key_matcher > matcher, jubatus::util::lang::shared_ptr< num_filter > filter, const std::string &suffix)
 
void register_num_rule (const std::string &name, jubatus::util::lang::shared_ptr< key_matcher > matcher, jubatus::util::lang::shared_ptr< num_feature > feature_func)
 
void register_string_filter (jubatus::util::lang::shared_ptr< key_matcher > matcher, jubatus::util::lang::shared_ptr< string_filter > filter, const std::string &suffix)
 
void register_string_rule (const std::string &name, jubatus::util::lang::shared_ptr< key_matcher > matcher, jubatus::util::lang::shared_ptr< string_feature > splitter, const std::vector< splitter_weight_type > &weights)
 
void revert_feature (const std::string &feature, std::pair< std::string, std::string > &expect) const
 
void set_hash_max_size (uint64_t hash_max_size)
 
void set_weight_manager (jubatus::util::lang::shared_ptr< weight_manager > wm)
 

Private Types

typedef jubatus::util::data::unordered_map< std::string, float > weight_t
 

Private Member Functions

bool contains_idf (const string_feature_rule &s) const
 
void convert_binaries (const datum::sv_t &binary_values, common::sfv_t &ret_fv) const
 
void convert_binaries (const binary_feature_rule &feature, const datum::sv_t &binary_values, common::sfv_t &ret_fv) const
 
void convert_combinations (common::sfv_t &ret_fv) const
 
void convert_num (const std::string &key, double value, common::sfv_t &ret_fv) const
 
void convert_nums (const datum::nv_t &num_values, common::sfv_t &ret_fv) const
 
void convert_strings (const datum::sv_t &string_values, common::sfv_t &ret_fv) const
 
void convert_strings (const string_feature_rule &splitter, const datum::sv_t &string_values, common::sfv_t &ret_fv) const
 
void count_words (const string_feature_rule &splitter, const std::string &key, const std::string &value, counter< std::string > &counter) const
 
void filter_nums (const datum::nv_t &num_values, datum::nv_t &filtered_values) const
 
void filter_strings (const datum::sv_t &string_values, datum::sv_t &filtered_values) const
 
std::string get_global_weight_name (term_weight_type type) const
 
double get_sample_weight (frequency_weight_type type, double tf, std::string &name) const
 
void make_string_features (const std::string &key, const std::string &splitter_name, const splitter_weight_type &weight_type, const counter< std::string > &count, common::sfv_t &ret_fv) const
 

Static Private Member Functions

static void check_key (const std::string &key)
 
static std::string make_feature (const std::string &key, const std::string &value, const std::string &splitter, const std::string &sample_weight, const std::string &global_weight)
 
static std::string make_feature_key (const std::string &key, const std::string &value, const std::string &splitter)
 

Private Attributes

std::vector< binary_feature_rulebinary_rules_
 
std::vector< combination_feature_rulecombination_rules_
 
jubatus::util::data::optional< feature_hasherhasher_
 
jubatus::util::lang::shared_ptr< mixable_weight_managermixable_weights_
 
std::vector< num_filter_rulenum_filter_rules_
 
std::vector< num_feature_rulenum_rules_
 
std::vector< string_filter_rulestring_filter_rules_
 
std::vector< string_feature_rulestring_rules_
 

Detailed Description

impl

Definition at line 48 of file datum_to_fv_converter.cpp.

Member Typedef Documentation

typedef jubatus::util::data::unordered_map<std::string, float> jubatus::core::fv_converter::datum_to_fv_converter_impl::weight_t
private

Definition at line 50 of file datum_to_fv_converter.cpp.

Constructor & Destructor Documentation

jubatus::core::fv_converter::datum_to_fv_converter_impl::datum_to_fv_converter_impl ( )
inline

Definition at line 167 of file datum_to_fv_converter.cpp.

170  jubatus::util::lang::shared_ptr<weight_manager>(
171  new weight_manager))) {
172  }
framework::linear_mixable_helper< weight_manager, versioned_weight_diff > mixable_weight_manager
jubatus::util::lang::shared_ptr< mixable_weight_manager > mixable_weights_

Member Function Documentation

void jubatus::core::fv_converter::datum_to_fv_converter_impl::add_weight ( const std::string &  key,
float  weight 
)
inline

Definition at line 235 of file datum_to_fv_converter.cpp.

235  {
236  jubatus::util::lang::shared_ptr<weight_manager> weights =
237  mixable_weights_->get_model();
238  if (weights) {
239  (*weights).add_weight(key, weight);
240  }
241  }
jubatus::util::lang::shared_ptr< mixable_weight_manager > mixable_weights_
static void jubatus::core::fv_converter::datum_to_fv_converter_impl::check_key ( const std::string &  key)
inlinestaticprivate

Definition at line 445 of file datum_to_fv_converter.cpp.

References JUBATUS_EXCEPTION.

Referenced by convert_binaries(), convert_num(), make_feature(), and make_feature_key().

445  {
446  if (key.find('$') != std::string::npos) {
447  throw JUBATUS_EXCEPTION(
448  converter_exception("feature key cannot contain '$': " + key));
449  }
450  }
#define JUBATUS_EXCEPTION(e)
Definition: exception.hpp:79

Here is the caller graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::clear_rules ( )
inline

Definition at line 174 of file datum_to_fv_converter.cpp.

174  {
175  string_filter_rules_.clear();
176  num_filter_rules_.clear();
177  string_rules_.clear();
178  num_rules_.clear();
179  binary_rules_.clear();
180  combination_rules_.clear();
181  }
std::vector< combination_feature_rule > combination_rules_
void jubatus::core::fv_converter::datum_to_fv_converter_impl::clear_weights ( )
inline

Definition at line 338 of file datum_to_fv_converter.cpp.

338  {
339  jubatus::util::lang::shared_ptr<weight_manager> weights =
340  mixable_weights_->get_model();
341  if (weights) {
342  weights->clear();
343  }
344  }
jubatus::util::lang::shared_ptr< mixable_weight_manager > mixable_weights_
bool jubatus::core::fv_converter::datum_to_fv_converter_impl::contains_idf ( const string_feature_rule s) const
inlineprivate

Definition at line 380 of file datum_to_fv_converter.cpp.

References jubatus::core::fv_converter::IDF, and jubatus::core::fv_converter::datum_to_fv_converter_impl::string_feature_rule::weights_.

380  {
381  for (size_t i = 0; i < s.weights_.size(); ++i) {
382  if (s.weights_[i].term_weight_type_ == IDF) {
383  return true;
384  }
385  }
386  return false;
387  }
void jubatus::core::fv_converter::datum_to_fv_converter_impl::convert ( const datum datum,
common::sfv_t ret_fv 
) const
inline

Definition at line 243 of file datum_to_fv_converter.cpp.

References convert_combinations(), and convert_unweighted().

243  {
244  common::sfv_t fv;
245  convert_unweighted(datum, fv);
246  jubatus::util::lang::shared_ptr<weight_manager> weights =
247  mixable_weights_->get_model();
248  if (weights) {
249  weights->get_weight(fv);
250  }
251 
253 
254  if (hasher_) {
255  hasher_->hash_feature_keys(fv);
256  }
257 
258  fv.swap(ret_fv);
259  }
jubatus::util::data::optional< feature_hasher > hasher_
jubatus::util::lang::shared_ptr< mixable_weight_manager > mixable_weights_
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29
void convert_unweighted(const datum &datum, common::sfv_t &ret_fv) const

Here is the call graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::convert_and_update_weight ( const datum datum,
common::sfv_t ret_fv 
)
inline

Definition at line 261 of file datum_to_fv_converter.cpp.

References convert_combinations(), and convert_unweighted().

261  {
262  common::sfv_t fv;
263  convert_unweighted(datum, fv);
264  jubatus::util::lang::shared_ptr<weight_manager> weights =
265  mixable_weights_->get_model();
266  if (weights) {
267  weights->update_weight(fv);
268  weights->get_weight(fv);
269  }
270 
272 
273  if (hasher_) {
274  hasher_->hash_feature_keys(fv);
275  }
276 
277  fv.swap(ret_fv);
278  }
jubatus::util::data::optional< feature_hasher > hasher_
jubatus::util::lang::shared_ptr< mixable_weight_manager > mixable_weights_
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29
void convert_unweighted(const datum &datum, common::sfv_t &ret_fv) const

Here is the call graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::convert_binaries ( const datum::sv_t binary_values,
common::sfv_t ret_fv 
) const
inlineprivate

Definition at line 405 of file datum_to_fv_converter.cpp.

Referenced by convert_unweighted().

406  {
407  for (size_t i = 0; i < binary_rules_.size(); ++i) {
408  convert_binaries(binary_rules_[i], binary_values, ret_fv);
409  }
410  }
void convert_binaries(const datum::sv_t &binary_values, common::sfv_t &ret_fv) const

Here is the caller graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::convert_binaries ( const binary_feature_rule feature,
const datum::sv_t binary_values,
common::sfv_t ret_fv 
) const
inlineprivate

Definition at line 412 of file datum_to_fv_converter.cpp.

References check_key(), jubatus::core::fv_converter::datum_to_fv_converter_impl::binary_feature_rule::feature_func_, and jubatus::core::fv_converter::datum_to_fv_converter_impl::binary_feature_rule::matcher_.

415  {
416  for (size_t j = 0; j < binary_values.size(); ++j) {
417  const std::string& key = binary_values[j].first;
418  const std::string& value = binary_values[j].second;
419  if (feature.matcher_->match(key)) {
420  check_key(key);
421  feature.feature_func_->add_feature(key, value, ret_fv);
422  }
423  }
424  }

Here is the call graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::convert_combinations ( common::sfv_t ret_fv) const
inlineprivate

Definition at line 548 of file datum_to_fv_converter.cpp.

References jubatus::core::fv_converter::datum_to_fv_converter_impl::combination_feature_rule::feature_func_, jubatus::core::fv_converter::datum_to_fv_converter_impl::combination_feature_rule::matcher_left_, jubatus::core::fv_converter::datum_to_fv_converter_impl::combination_feature_rule::matcher_right_, and jubatus::core::fv_converter::datum_to_fv_converter_impl::combination_feature_rule::name_.

Referenced by convert(), and convert_and_update_weight().

548  {
549  const size_t original_size = ret_fv.size();
550 
551  if (original_size < 2) {
552  // Must have at least 2 features to generate combinations.
553  return;
554  }
555 
556  for (size_t i = 0; i < combination_rules_.size(); ++i) {
557  const combination_feature_rule& r = combination_rules_[i];
558  for (size_t j = 0 ; j < original_size - 1; ++j) {
559  for (size_t m = j + 1; m < original_size; ++m) {
560  if (r.matcher_left_->match(ret_fv[j].first)
561  && r.matcher_right_->match(ret_fv[m].first)) {
562  r.feature_func_->add_feature(
563  ret_fv[j].first + "&" + ret_fv[m].first + "/" + r.name_,
564  ret_fv[j].second,
565  ret_fv[m].second,
566  ret_fv);
567  }
568  }
569  }
570  }
571  }
std::vector< combination_feature_rule > combination_rules_

Here is the caller graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::convert_num ( const std::string &  key,
double  value,
common::sfv_t ret_fv 
) const
inlineprivate

Definition at line 535 of file datum_to_fv_converter.cpp.

References check_key(), jubatus::core::fv_converter::datum_to_fv_converter_impl::num_feature_rule::feature_func_, jubatus::core::fv_converter::datum_to_fv_converter_impl::num_feature_rule::matcher_, and jubatus::core::fv_converter::datum_to_fv_converter_impl::num_feature_rule::name_.

Referenced by convert_nums().

537  {
538  for (size_t i = 0; i < num_rules_.size(); ++i) {
539  const num_feature_rule& r = num_rules_[i];
540  if (r.matcher_->match(key)) {
541  check_key(key);
542  std::string k = key + "@" + r.name_;
543  r.feature_func_->add_feature(k, value, ret_fv);
544  }
545  }
546  }

Here is the call graph for this function:

Here is the caller graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::convert_nums ( const datum::nv_t num_values,
common::sfv_t ret_fv 
) const
inlineprivate

Definition at line 528 of file datum_to_fv_converter.cpp.

References convert_num().

Referenced by convert_unweighted().

529  {
530  for (size_t i = 0; i < num_values.size(); ++i) {
531  convert_num(num_values[i].first, num_values[i].second, ret_fv);
532  }
533  }
void convert_num(const std::string &key, double value, common::sfv_t &ret_fv) const

Here is the call graph for this function:

Here is the caller graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::convert_strings ( const datum::sv_t string_values,
common::sfv_t ret_fv 
) const
inlineprivate

Definition at line 373 of file datum_to_fv_converter.cpp.

Referenced by convert_unweighted().

374  {
375  for (size_t i = 0; i < string_rules_.size(); ++i) {
376  convert_strings(string_rules_[i], string_values, ret_fv);
377  }
378  }
void convert_strings(const datum::sv_t &string_values, common::sfv_t &ret_fv) const

Here is the caller graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::convert_strings ( const string_feature_rule splitter,
const datum::sv_t string_values,
common::sfv_t ret_fv 
) const
inlineprivate

Definition at line 389 of file datum_to_fv_converter.cpp.

References count_words(), make_string_features(), jubatus::core::fv_converter::datum_to_fv_converter_impl::string_feature_rule::name_, and jubatus::core::fv_converter::datum_to_fv_converter_impl::string_feature_rule::weights_.

392  {
393  for (size_t j = 0; j < string_values.size(); ++j) {
394  const std::string& key = string_values[j].first;
395  const std::string& value = string_values[j].second;
396  counter<std::string> counter;
397  count_words(splitter, key, value, counter);
398  for (size_t i = 0; i < splitter.weights_.size(); ++i) {
400  key, splitter.name_, splitter.weights_[i], counter, ret_fv);
401  }
402  }
403  }
void make_string_features(const std::string &key, const std::string &splitter_name, const splitter_weight_type &weight_type, const counter< std::string > &count, common::sfv_t &ret_fv) const
void count_words(const string_feature_rule &splitter, const std::string &key, const std::string &value, counter< std::string > &counter) const

Here is the call graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::convert_unweighted ( const datum datum,
common::sfv_t ret_fv 
) const
inline

Definition at line 280 of file datum_to_fv_converter.cpp.

References jubatus::core::fv_converter::datum::binary_values_, convert_binaries(), convert_nums(), convert_strings(), filter_nums(), filter_strings(), jubatus::core::fv_converter::datum::num_values_, and jubatus::core::fv_converter::datum::string_values_.

Referenced by convert(), and convert_and_update_weight().

280  {
281  common::sfv_t fv;
282 
283  std::vector<std::pair<std::string, std::string> > filtered_strings;
284  filter_strings(datum.string_values_, filtered_strings);
285  convert_strings(datum.string_values_, fv);
286  convert_strings(filtered_strings, fv);
287 
288  std::vector<std::pair<std::string, double> > filtered_nums;
289  filter_nums(datum.num_values_, filtered_nums);
290  convert_nums(datum.num_values_, fv);
291  convert_nums(filtered_nums, fv);
292 
293  convert_binaries(datum.binary_values_, fv);
294 
295  fv.swap(ret_fv);
296  }
void filter_strings(const datum::sv_t &string_values, datum::sv_t &filtered_values) const
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29
void convert_binaries(const datum::sv_t &binary_values, common::sfv_t &ret_fv) const
void filter_nums(const datum::nv_t &num_values, datum::nv_t &filtered_values) const
void convert_strings(const datum::sv_t &string_values, common::sfv_t &ret_fv) const
void convert_nums(const datum::nv_t &num_values, common::sfv_t &ret_fv) const

Here is the call graph for this function:

Here is the caller graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::count_words ( const string_feature_rule splitter,
const std::string &  key,
const std::string &  value,
counter< std::string > &  counter 
) const
inlineprivate

Definition at line 452 of file datum_to_fv_converter.cpp.

References jubatus::core::fv_converter::datum_to_fv_converter_impl::string_feature_rule::matcher_, and jubatus::core::fv_converter::datum_to_fv_converter_impl::string_feature_rule::splitter_.

Referenced by convert_strings().

456  {
457  if (splitter.matcher_->match(key)) {
458  std::vector<string_feature_element> elements;
459  splitter.splitter_->extract(value, elements);
460 
461  for (size_t i = 0; i < elements.size(); i++) {
462  counter[elements[i].value] += elements[i].score;
463  }
464  }
465  }

Here is the caller graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::filter_nums ( const datum::nv_t num_values,
datum::nv_t filtered_values 
) const
inlineprivate

Definition at line 360 of file datum_to_fv_converter.cpp.

Referenced by convert_unweighted().

362  {
363  for (size_t i = 0; i < num_filter_rules_.size(); ++i) {
364  datum::nv_t update;
365  num_filter_rules_[i].filter(num_values, update);
366  num_filter_rules_[i].filter(filtered_values, update);
367 
368  filtered_values.insert(
369  filtered_values.end(), update.begin(), update.end());
370  }
371  }
std::vector< std::pair< std::string, double > > nv_t
Definition: datum.hpp:33

Here is the caller graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::filter_strings ( const datum::sv_t string_values,
datum::sv_t filtered_values 
) const
inlineprivate

Definition at line 347 of file datum_to_fv_converter.cpp.

Referenced by convert_unweighted().

349  {
350  for (size_t i = 0; i < string_filter_rules_.size(); ++i) {
351  datum::sv_t update;
352  string_filter_rules_[i].filter(string_values, update);
353  string_filter_rules_[i].filter(filtered_values, update);
354 
355  filtered_values.insert(filtered_values.end(), update.begin(),
356  update.end());
357  }
358  }
std::vector< std::pair< std::string, std::string > > sv_t
Definition: datum.hpp:32

Here is the caller graph for this function:

std::string jubatus::core::fv_converter::datum_to_fv_converter_impl::get_global_weight_name ( term_weight_type  type) const
inlineprivate

Definition at line 489 of file datum_to_fv_converter.cpp.

References jubatus::core::fv_converter::IDF, JUBATUS_EXCEPTION, jubatus::core::fv_converter::TERM_BINARY, and jubatus::core::fv_converter::WITH_WEIGHT_FILE.

Referenced by make_string_features().

489  {
490  switch (type) {
491  case TERM_BINARY:
492  return "bin";
493  case IDF:
494  return "idf";
495  case WITH_WEIGHT_FILE:
496  return "weight";
497  default:
498  throw JUBATUS_EXCEPTION(
500  "unknown global weight type"));
501  }
502  }
#define JUBATUS_EXCEPTION(e)
Definition: exception.hpp:79

Here is the caller graph for this function:

double jubatus::core::fv_converter::datum_to_fv_converter_impl::get_sample_weight ( frequency_weight_type  type,
double  tf,
std::string &  name 
) const
inlineprivate

Definition at line 467 of file datum_to_fv_converter.cpp.

References jubatus::core::fv_converter::FREQ_BINARY, jubatus::core::fv_converter::LOG_TERM_FREQUENCY, and jubatus::core::fv_converter::TERM_FREQUENCY.

Referenced by make_string_features().

470  {
471  switch (type) {
472  case FREQ_BINARY:
473  name = "bin";
474  return 1.0;
475 
476  case TERM_FREQUENCY:
477  name = "tf";
478  return tf;
479 
480  case LOG_TERM_FREQUENCY:
481  name = "log_tf";
482  return std::log(1. + tf);
483 
484  default:
485  return 0;
486  }
487  }

Here is the caller graph for this function:

static std::string jubatus::core::fv_converter::datum_to_fv_converter_impl::make_feature ( const std::string &  key,
const std::string &  value,
const std::string &  splitter,
const std::string &  sample_weight,
const std::string &  global_weight 
)
inlinestaticprivate

Definition at line 426 of file datum_to_fv_converter.cpp.

References check_key().

Referenced by make_string_features().

431  {
432  check_key(key);
433  return key + "$" + value + "@" + splitter + "#" + sample_weight + "/" +
434  global_weight;
435  }

Here is the call graph for this function:

Here is the caller graph for this function:

static std::string jubatus::core::fv_converter::datum_to_fv_converter_impl::make_feature_key ( const std::string &  key,
const std::string &  value,
const std::string &  splitter 
)
inlinestaticprivate

Definition at line 437 of file datum_to_fv_converter.cpp.

References check_key().

440  {
441  check_key(key);
442  return key + "$" + value + "@" + splitter;
443  }

Here is the call graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::make_string_features ( const std::string &  key,
const std::string &  splitter_name,
const splitter_weight_type weight_type,
const counter< std::string > &  count,
common::sfv_t ret_fv 
) const
inlineprivate

Definition at line 504 of file datum_to_fv_converter.cpp.

References jubatus::core::fv_converter::counter< T >::begin(), jubatus::core::fv_converter::counter< T >::end(), jubatus::core::fv_converter::splitter_weight_type::freq_weight_type_, get_global_weight_name(), get_sample_weight(), make_feature(), jubatus::core::fv_converter::splitter_weight_type::term_weight_type_, and jubatus::core::common::jsonconfig::v().

Referenced by convert_strings().

509  {
511  it != count.end(); ++it) {
512  std::string sample_weight_name;
513  double sample_weight = get_sample_weight(
514  weight_type.freq_weight_type_, it->second, sample_weight_name);
515 
516  std::string global_weight_name = get_global_weight_name(
517  weight_type.term_weight_type_);
518  float v = static_cast<float>(sample_weight);
519  if (v != 0.0) {
520  std::string f = make_feature(
521  key, it->first, splitter_name, sample_weight_name,
522  global_weight_name);
523  ret_fv.push_back(std::make_pair(f, v));
524  }
525  }
526  }
static std::string make_feature(const std::string &key, const std::string &value, const std::string &splitter, const std::string &sample_weight, const std::string &global_weight)
jubatus::util::data::unordered_map< std::string, double >::const_iterator const_iterator
Definition: counter.hpp:35
const_iterator begin() const
Definition: counter.hpp:59
std::string get_global_weight_name(term_weight_type type) const
std::vector< T > v(size)
double get_sample_weight(frequency_weight_type type, double tf, std::string &name) const
const_iterator end() const
Definition: counter.hpp:67

Here is the call graph for this function:

Here is the caller graph for this function:

void jubatus::core::fv_converter::datum_to_fv_converter_impl::register_binary_rule ( const std::string &  name,
jubatus::util::lang::shared_ptr< key_matcher matcher,
jubatus::util::lang::shared_ptr< binary_feature feature_func 
)
inline

Definition at line 215 of file datum_to_fv_converter.cpp.

218  {
219  binary_rules_.push_back(binary_feature_rule(name, matcher, feature_func));
220  }
void jubatus::core::fv_converter::datum_to_fv_converter_impl::register_combination_rule ( const std::string &  name,
jubatus::util::lang::shared_ptr< key_matcher matcher_left,
jubatus::util::lang::shared_ptr< key_matcher matcher_right,
jubatus::util::lang::shared_ptr< combination_feature feature_func 
)
inline

Definition at line 222 of file datum_to_fv_converter.cpp.

226  {
227  combination_rules_.push_back(
228  combination_feature_rule(
229  name,
230  matcher_left,
231  matcher_right,
232  feature_func));
233  }
std::vector< combination_feature_rule > combination_rules_
void jubatus::core::fv_converter::datum_to_fv_converter_impl::register_num_filter ( jubatus::util::lang::shared_ptr< key_matcher matcher,
jubatus::util::lang::shared_ptr< num_filter filter,
const std::string &  suffix 
)
inline

Definition at line 191 of file datum_to_fv_converter.cpp.

194  {
195  num_filter_rule rule = { matcher, filter, suffix };
196  num_filter_rules_.push_back(rule);
197  }
void jubatus::core::fv_converter::datum_to_fv_converter_impl::register_num_rule ( const std::string &  name,
jubatus::util::lang::shared_ptr< key_matcher matcher,
jubatus::util::lang::shared_ptr< num_feature feature_func 
)
inline

Definition at line 208 of file datum_to_fv_converter.cpp.

211  {
212  num_rules_.push_back(num_feature_rule(name, matcher, feature_func));
213  }
void jubatus::core::fv_converter::datum_to_fv_converter_impl::register_string_filter ( jubatus::util::lang::shared_ptr< key_matcher matcher,
jubatus::util::lang::shared_ptr< string_filter filter,
const std::string &  suffix 
)
inline

Definition at line 183 of file datum_to_fv_converter.cpp.

186  {
187  string_filter_rule rule = { matcher, filter, suffix };
188  string_filter_rules_.push_back(rule);
189  }
void jubatus::core::fv_converter::datum_to_fv_converter_impl::register_string_rule ( const std::string &  name,
jubatus::util::lang::shared_ptr< key_matcher matcher,
jubatus::util::lang::shared_ptr< string_feature splitter,
const std::vector< splitter_weight_type > &  weights 
)
inline

Definition at line 199 of file datum_to_fv_converter.cpp.

203  {
204  string_rules_.push_back(
205  string_feature_rule(name, matcher, splitter, weights));
206  }
void jubatus::core::fv_converter::datum_to_fv_converter_impl::revert_feature ( const std::string &  feature,
std::pair< std::string, std::string > &  expect 
) const
inline

Definition at line 298 of file datum_to_fv_converter.cpp.

References JUBATUS_EXCEPTION.

300  {
301  // format of string feature is
302  // "<KEY_NAME>$<VALUE>@<FEATURE_TYPE>#<SAMPLE_WEIGHT>/<GLOBAL_WEIGHT>"
303  size_t sharp = feature.rfind('#');
304  if (sharp == std::string::npos) {
305  throw JUBATUS_EXCEPTION(
306  converter_exception("this feature is not string feature"));
307  }
308  size_t at = feature.rfind('@', sharp);
309  if (at == std::string::npos) {
310  throw JUBATUS_EXCEPTION(
311  converter_exception("this feature is not valid feature"));
312  }
313  size_t dollar = feature.rfind('$', at);
314  if (dollar == std::string::npos) {
315  throw JUBATUS_EXCEPTION(
316  converter_exception("this feature is not valid feature"));
317  }
318  if (feature.substr(at + 1, sharp - at - 1) != "str") {
319  throw JUBATUS_EXCEPTION(
320  converter_exception("this feature is not revertible"));
321  }
322 
323  std::string key(feature.substr(0, dollar));
324  std::string value(feature.substr(dollar + 1, at - dollar - 1));
325 
326  expect.first.swap(key);
327  expect.second.swap(value);
328  }
#define JUBATUS_EXCEPTION(e)
Definition: exception.hpp:79
void jubatus::core::fv_converter::datum_to_fv_converter_impl::set_hash_max_size ( uint64_t  hash_max_size)
inline

Definition at line 330 of file datum_to_fv_converter.cpp.

330  {
331  hasher_ = feature_hasher(hash_max_size);
332  }
jubatus::util::data::optional< feature_hasher > hasher_
void jubatus::core::fv_converter::datum_to_fv_converter_impl::set_weight_manager ( jubatus::util::lang::shared_ptr< weight_manager wm)
inline

Definition at line 334 of file datum_to_fv_converter.cpp.

334  {
335  mixable_weights_->set_model(wm);
336  }
jubatus::util::lang::shared_ptr< mixable_weight_manager > mixable_weights_

Member Data Documentation

std::vector<binary_feature_rule> jubatus::core::fv_converter::datum_to_fv_converter_impl::binary_rules_
private

Definition at line 154 of file datum_to_fv_converter.cpp.

std::vector<combination_feature_rule> jubatus::core::fv_converter::datum_to_fv_converter_impl::combination_rules_
private

Definition at line 155 of file datum_to_fv_converter.cpp.

jubatus::util::data::optional<feature_hasher> jubatus::core::fv_converter::datum_to_fv_converter_impl::hasher_
private

Definition at line 164 of file datum_to_fv_converter.cpp.

jubatus::util::lang::shared_ptr<mixable_weight_manager> jubatus::core::fv_converter::datum_to_fv_converter_impl::mixable_weights_
private

Definition at line 162 of file datum_to_fv_converter.cpp.

std::vector<num_filter_rule> jubatus::core::fv_converter::datum_to_fv_converter_impl::num_filter_rules_
private

Definition at line 158 of file datum_to_fv_converter.cpp.

std::vector<num_feature_rule> jubatus::core::fv_converter::datum_to_fv_converter_impl::num_rules_
private

Definition at line 160 of file datum_to_fv_converter.cpp.

std::vector<string_filter_rule> jubatus::core::fv_converter::datum_to_fv_converter_impl::string_filter_rules_
private

Definition at line 157 of file datum_to_fv_converter.cpp.

std::vector<string_feature_rule> jubatus::core::fv_converter::datum_to_fv_converter_impl::string_rules_
private

Definition at line 159 of file datum_to_fv_converter.cpp.


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