Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "classifiers.h"
- #include <memory>
- class CombinedClassifier {
- private:
- std::unique_ptr<MainClassifier> p1;
- std::unique_ptr<FastClassifier> p2;
- std::string str;
- public:
- CombinedClassifier(const std::string& s1, const std::string& s2) {
- p1.reset(new MainClassifier(s1));
- str(s2);
- }
- double classify(const string& s) {
- try {
- return p1->classify(s);
- }
- catch (TooHardObjectException()) {
- if (p2 == nullptr) {
- p2.reset(new FastClassifier(str));
- }
- return p2->classify(s);
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement