jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
datum_to_fv_converter.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2011 Preferred Networks and Nippon Telegraph and Telephone Corporation.
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License version 2.1 as published by the Free Software Foundation.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 #ifndef JUBATUS_CORE_FV_CONVERTER_DATUM_TO_FV_CONVERTER_HPP_
18 #define JUBATUS_CORE_FV_CONVERTER_DATUM_TO_FV_CONVERTER_HPP_
19 
20 #include <string>
21 #include <utility>
22 #include <vector>
23 #include "jubatus/util/data/unordered_map.h"
24 #include "jubatus/util/lang/shared_ptr.h"
25 #include "jubatus/util/lang/scoped_ptr.h"
26 #include "../common/type.hpp"
27 #include "../framework/mixable.hpp"
28 
29 namespace jubatus {
30 namespace core {
31 namespace fv_converter {
32 
37 };
38 
41  IDF,
43 };
44 
48 
50  frequency_weight_type freq_weight_type,
52  : freq_weight_type_(freq_weight_type),
53  term_weight_type_(term_weight_type) {
54  }
55 };
56 
57 struct datum;
58 class datum_to_fv_converter_impl;
59 class key_matcher;
60 class num_feature;
61 class binary_feature;
62 class combination_feature;
63 class string_filter;
64 class num_filter;
65 class string_feature;
66 class weight_manager;
67 
69  public:
71 
73 
74  void convert(const datum& datum, common::sfv_t& ret_fv) const;
75 
76  void convert_and_update_weight(const datum& datum, common::sfv_t& ret_fv);
77 
78  void clear_rules();
79 
81  jubatus::util::lang::shared_ptr<key_matcher> matcher,
82  jubatus::util::lang::shared_ptr<string_filter> filter,
83  const std::string& suffix);
84 
86  jubatus::util::lang::shared_ptr<key_matcher> matcher,
87  jubatus::util::lang::shared_ptr<num_filter> filter,
88  const std::string& suffix);
89 
91  const std::string& name,
92  jubatus::util::lang::shared_ptr<key_matcher> matcher,
93  jubatus::util::lang::shared_ptr<string_feature> splitter,
94  const std::vector<splitter_weight_type>& weights);
95 
96  void register_num_rule(
97  const std::string& name,
98  jubatus::util::lang::shared_ptr<key_matcher> matcher,
99  jubatus::util::lang::shared_ptr<num_feature> feature_func);
100 
102  const std::string& name,
103  jubatus::util::lang::shared_ptr<key_matcher> matcher,
104  jubatus::util::lang::shared_ptr<binary_feature> feature_func);
105 
107  const std::string& name,
108  jubatus::util::lang::shared_ptr<key_matcher> matcher_left,
109  jubatus::util::lang::shared_ptr<key_matcher> matcher_right,
110  jubatus::util::lang::shared_ptr<combination_feature> feature_func);
111 
112  void add_weight(const std::string& key, float weight);
113 
114  void revert_feature(
115  const std::string& feature,
116  std::pair<std::string, std::string>& expect) const;
117 
118  void set_hash_max_size(uint64_t hash_max_size);
119 
120  void set_weight_manager(jubatus::util::lang::shared_ptr<weight_manager> wm);
121  void clear_weights();
122 
123  private:
124  jubatus::util::lang::scoped_ptr<datum_to_fv_converter_impl> pimpl_;
125 };
126 
127 } // namespace fv_converter
128 } // namespace core
129 } // namespace jubatus
130 
131 #endif // JUBATUS_CORE_FV_CONVERTER_DATUM_TO_FV_CONVERTER_HPP_
void convert(const datum &datum, common::sfv_t &ret_fv) const
void revert_feature(const std::string &feature, std::pair< std::string, std::string > &expect) const
splitter_weight_type(frequency_weight_type freq_weight_type, term_weight_type term_weight_type)
void convert_and_update_weight(const datum &datum, common::sfv_t &ret_fv)
void set_weight_manager(jubatus::util::lang::shared_ptr< weight_manager > wm)
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 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_num_rule(const std::string &name, jubatus::util::lang::shared_ptr< key_matcher > matcher, jubatus::util::lang::shared_ptr< num_feature > feature_func)
void add_weight(const std::string &key, float weight)
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)
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29
void register_num_filter(jubatus::util::lang::shared_ptr< key_matcher > matcher, jubatus::util::lang::shared_ptr< num_filter > filter, const std::string &suffix)
jubatus::util::lang::scoped_ptr< datum_to_fv_converter_impl > pimpl_