Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include "classifiers.h"
  2. #include <memory>
  3.  
  4. class CombinedClassifier {
  5. private:
  6.     std::unique_ptr<MainClassifier> mc;
  7.     string mc_data;
  8.     std::unique_ptr<FastClassifier> fc;
  9.  
  10. public:
  11.     CombinedClassifier(const string& s1, const string& s2) {
  12.         fc = new FastClassifier(s1);
  13.         mc_data = s2;
  14.         mc = nullptr;
  15.     }
  16.  
  17.     double classify(const string& s) {
  18.         double ans;
  19.         try {
  20.             ans = (*fc).classify(s);
  21.         }
  22.         catch (TooHardObjectException& t) {
  23.             if (mc == nullptr) {
  24.                 mc = new MainClassifier(mc_data);
  25.             }
  26.             ans = (*mc).classify(s);
  27.         }
  28.         return ans;
  29.     }
  30. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement