ModErn Text Analysis
META Enumerates Textual Applications
binary_classifier_factory.h
Go to the documentation of this file.
1 
10 #ifndef META_BINARY_CLASSIFIER_FACTORY_H_
11 #define META_BINARY_CLASSIFIER_FACTORY_H_
12 
14 #include "util/factory.h"
15 
16 namespace cpptoml
17 {
18 class table;
19 }
20 
21 namespace meta
22 {
23 namespace classify
24 {
25 
33  : public util::factory<binary_classifier_factory, binary_classifier,
34  const cpptoml::table&,
35  std::shared_ptr<index::forward_index>, class_label,
36  class_label>
37 {
38  friend base_factory;
39 
40  private:
45 
49  template <class Classifier>
50  void reg();
51 };
52 
53 // doxygen is being stupid here, so I'm forced to specify which overload
54 // I'm talking about in their brief...
69 std::unique_ptr<binary_classifier>
70  make_binary_classifier(const cpptoml::table& config,
71  std::shared_ptr<index::forward_index> idx,
72  class_label positive, class_label negative);
73 
89 template <class Classifier>
90 std::unique_ptr<binary_classifier>
91  make_binary_classifier(const cpptoml::table&,
92  std::shared_ptr<index::forward_index> idx,
93  class_label positive, class_label negative)
94 {
95  return make_unique<Classifier>(std::move(idx), positive, negative);
96 }
97 
102 template <class Classifier>
104 {
105  binary_classifier_factory::get().add(Classifier::id,
106  make_binary_classifier<Classifier>);
107 }
108 }
109 }
110 #endif
void add(const std::string &identifier, Function &&fn)
Associates the given identifier with the given factory method.
Definition: factory.h:61
std::unique_ptr< binary_classifier > make_binary_classifier(const cpptoml::table &config, std::shared_ptr< index::forward_index > idx, class_label positive, class_label negative)
(Non-template): Convenience method for creating a binary classifier using the factory.
Definition: binary_classifier_factory.h:91
Generic factory that can be subclassed to create factories for specific types.
Definition: factory.h:27
Factory that is responsible for creating binary classifiers from configuration files.
Definition: binary_classifier_factory.h:32
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
binary_classifier_factory()
Constructs the binary_classifier_factory singleton.
Definition: binary_classifier_factory.cpp:20
void register_binary_classifier()
Registration method for binary classifiers.
Definition: binary_classifier_factory.h:103
void reg()
Registers a classifier with the factory (used internally).
Definition: binary_classifier_factory.cpp:15
Definition: analyzer.h:19