daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest Oct 15th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "classifiers.h"
  2. #include <memory>
  3.  
  4. class CombinedClassifier {
  5. private:
  6.     std::unique_ptr<FastClassifier> p1;
  7.     std::unique_ptr<MainClassifier> p2;
  8.     std::string str;
  9. public:
  10.     CombinedClassifier(const std::string& s1, const std::string& s2) {
  11.         p1.reset(new FastClassifier(s1));
  12.         str = s2;
  13.     }
  14.     double classify(const string& s) {
  15.         try {
  16.             return p1->classify(s);
  17.         }
  18.         catch (TooHardObjectException()) {
  19.             if (!p2) {
  20.                 p2.reset(new MainClassifier(str));
  21.             }
  22.             return p2->classify(s);
  23.         }
  24.     }
  25. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top