jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Functions
test_util.hpp File Reference
#include <string>
#include <sstream>
#include <vector>
#include "jubatus/util/math/random.h"
#include "../fv_converter/converter_config.hpp"
#include "../fv_converter/datum_to_fv_converter.hpp"
#include "../fv_converter/datum.hpp"
#include "../framework/mixable.hpp"
Include dependency graph for test_util.hpp:

Go to the source code of this file.

Functions

jubatus::core::fv_converter::datum generate_random_datum (jubatus::util::math::random::mtrand &rand, int datum_length)
 
std::string generate_random_string (jubatus::util::math::random::mtrand &rand, int length)
 
jubatus::util::lang::shared_ptr< jubatus::core::fv_converter::datum_to_fv_convertermake_fv_converter ()
 
jubatus::util::lang::shared_ptr< jubatus::core::fv_converter::datum_to_fv_convertermake_tf_idf_fv_converter ()
 

Function Documentation

jubatus::core::fv_converter::datum generate_random_datum ( jubatus::util::math::random::mtrand &  rand,
int  datum_length 
)

Definition at line 68 of file test_util.hpp.

References generate_random_string(), and jubatus::core::fv_converter::datum::string_values_.

70  {
72  std::string value = generate_random_string(rand, datum_length);
73  d.string_values_.push_back(std::make_pair("key", value));
74  return d;
75 }
std::string generate_random_string(jubatus::util::math::random::mtrand &rand, int length)
Definition: test_util.hpp:56

Here is the call graph for this function:

std::string generate_random_string ( jubatus::util::math::random::mtrand &  rand,
int  length 
)

Definition at line 56 of file test_util.hpp.

Referenced by generate_random_datum().

57  {
58  static const std::string alphabets =
59  "abcdefghijklmnopqrstuvwxyz"
60  "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
61  std::string ret(length, 'a');
62  for (int i = 0; i < length; ++i) {
63  ret[i] = alphabets[rand.next_int(alphabets.length())];
64  }
65  return ret;
66 }

Here is the caller graph for this function:

jubatus::util::lang::shared_ptr<jubatus::core::fv_converter::datum_to_fv_converter> make_fv_converter ( )

Definition at line 32 of file test_util.hpp.

References jubatus::core::fv_converter::string_rule::global_weight, jubatus::core::fv_converter::initialize_converter(), jubatus::core::fv_converter::string_rule::key, jubatus::core::fv_converter::num_rule::key, jubatus::core::fv_converter::converter_config::num_rules, jubatus::core::fv_converter::string_rule::sample_weight, jubatus::core::fv_converter::converter_config::string_rules, jubatus::core::fv_converter::string_rule::type, and jubatus::core::fv_converter::num_rule::type.

32  {
33  jubatus::util::lang::shared_ptr<jubatus::core::fv_converter::datum_to_fv_converter> // NOLINT
34  converter(
36 
38  str_rule.key = "*";
39  str_rule.type = "str";
40  str_rule.sample_weight = "bin";
41  str_rule.global_weight = "bin";
43  num_rule.key = "*";
44  num_rule.type = "num";
45 
47  c.string_rules = std::vector<jubatus::core::fv_converter::string_rule>();
48  c.string_rules->push_back(str_rule);
49  c.num_rules = std::vector<jubatus::core::fv_converter::num_rule>();
50  c.num_rules->push_back(num_rule);
51 
53  return converter;
54 }
void initialize_converter(const converter_config &config, datum_to_fv_converter &conv, const factory_extender *ext)
jubatus::util::data::optional< std::vector< num_rule > > num_rules
jubatus::util::data::optional< std::vector< string_rule > > string_rules

Here is the call graph for this function:

jubatus::util::lang::shared_ptr<jubatus::core::fv_converter::datum_to_fv_converter> make_tf_idf_fv_converter ( )

Definition at line 78 of file test_util.hpp.

References jubatus::core::fv_converter::string_rule::global_weight, jubatus::core::fv_converter::initialize_converter(), jubatus::core::fv_converter::string_rule::key, jubatus::core::fv_converter::string_rule::sample_weight, jubatus::core::fv_converter::converter_config::string_rules, and jubatus::core::fv_converter::string_rule::type.

78  {
79  jubatus::util::lang::shared_ptr<jubatus::core::fv_converter::datum_to_fv_converter> // NOLINT
80  converter(
82 
84  str_rule.key = "*";
85  str_rule.type = "space";
86  str_rule.sample_weight = "tf";
87  str_rule.global_weight = "idf";
88 
90  c.string_rules = std::vector<jubatus::core::fv_converter::string_rule>();
91  c.string_rules->push_back(str_rule);
92 
94  return converter;
95 }
void initialize_converter(const converter_config &config, datum_to_fv_converter &conv, const factory_extender *ext)
jubatus::util::data::optional< std::vector< string_rule > > string_rules

Here is the call graph for this function: