jubatus::fv_converter::num_feature* create(std::map<std::string, std::string>& params) {
   const std::string& min_str = get_or_die(params, "min");
   const std::string& max_str = get_or_die(params, "max");
   double min_ = pfi::lang::lexical_cast<double>(min_str);
   double max_ = pfi::lang::lexical_cast<double>(max_str);
   if (min_ == max_) {
     throw JUBATUS_EXCEPTION(jubatus::fv_converter::converter_exception(std::string("MAX equals to MIN.")));
   }
   return new normalize_num_feature(max_, min_);
 }
Example #2
0
const int get_int_or_die(const map<string, string>& params,
                         const string& key) {
  const string& s = get_or_die(params, key);
  try {
    return pfi::lang::lexical_cast<int>(s);
  } catch (const bad_cast& e) {
    throw JUBATUS_EXCEPTION(converter_exception(string("\"" + key + "\" must be an integer value: " + s)));
  }
}
Example #3
0
void init_num_filter_types(
    const std::map<std::string, param_t>& filter_types,
    std::map<std::string, num_filter_ptr>& filters) {
  num_filter_factory f;
  for (std::map<std::string, param_t>::const_iterator it = filter_types.begin();
      it != filter_types.end(); ++it) {
    const std::string& name = it->first;
    const std::map<std::string, std::string>& param = it->second;

    std::string method = get_or_die(param, "method");
    num_filter_ptr filter(f.create(method, param));
    filters[name] = filter;
  }
}
Example #4
0
void init_string_types(
    const std::map<std::string, param_t>& string_types,
    std::map<std::string, splitter_ptr>& splitters) {
  // default
  splitters["str"] = splitter_ptr(new without_split());
  splitters["space"] = splitter_ptr(new space_splitter());

  splitter_factory f;
  for (std::map<std::string, param_t>::const_iterator it = string_types.begin();
      it != string_types.end(); ++it) {
    const std::string& name = it->first;
    const std::map<std::string, std::string>& param = it->second;

    std::string method = get_or_die(param, "method");
    splitter_ptr splitter(f.create(method, param));
    splitters[name] = splitter;
  }
}
Example #5
0
void init_num_types(
    const std::map<std::string, param_t>& num_types,
    std::map<std::string, num_feature_ptr>& num_features) {
  // default
  num_features["num"] = num_feature_ptr(new num_value_feature());
  num_features["log"] = num_feature_ptr(new num_log_feature());
  num_features["str"] = num_feature_ptr(new num_string_feature());

  num_feature_factory f;
  for (std::map<std::string, param_t>::const_iterator it = num_types.begin();
      it != num_types.end(); ++it) {
    const std::string& name = it->first;
    const std::map<std::string, std::string>& param = it->second;

    std::string method = get_or_die(param, "method");
    num_feature_ptr feature(f.create(method, param));
    num_features[name] = feature;
  }
}
static
string_filter* create_dynamic_filter(const string_filter_factory::param_t& params) {
    const string& path = get_or_die(params, "path");
    const string& function = get_or_die(params, "function");
    return new dynamic_string_filter(path, function, params);
}
static
re2_filter* create_re2_filter(const string_filter_factory::param_t& params) {
    const string& pattern = get_or_die(params, "pattern");
    const string& replace = get_or_die(params, "replace");
    return new re2_filter(pattern, replace);
}
Example #8
0
static
num_filter* create_dynamic_filter(const map<string, string>& params) {
  const string& path = get_or_die(params, "path");
  const string& function = get_or_die(params, "function");
  return new dynamic_num_filter(path, function, params);
}
Example #9
0
static
add_filter* create_add_filter(const map<string, string>& params) {
  const string& value = get_or_die(params, "value");
  double float_val = pfi::lang::lexical_cast<double>(value);
  return new add_filter(float_val);
}
Example #10
0
num_feature* create_dynamic_num_feature(const num_feature_factory::param_t& params) {
  const string& path = get_or_die(params, "path");
  const string& function = get_or_die(params, "function");
  return new dynamic_num_feature(path, function, params);
}