Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <memory>
  2. #include "classifiers.h"
  3. using std::cout;
  4. using std::string;
  5. using std::vector;
  6.  
  7.  
  8.  
  9. class CombinedClassifier {
  10. private:
  11.     string fast_class, slow_class;
  12.     FastClassifier * fast;
  13.     MainClassifier * slow = nullptr;
  14. public:
  15.     CombinedClassifier(string& s1, string& s2): fast_class(s1), slow_class(s2) {
  16.         fast = new FastClassifier(fast_class);
  17.     }
  18.  
  19.     double classify(const string& s) {
  20.         try {
  21.             double ans;
  22.             ans = fast->classify(s);
  23.             return ans;
  24.         } catch (const TooHardObjectException&) {
  25.             if (slow == nullptr) {
  26.                 slow = new MainClassifier(slow_class);
  27.                 return slow->classify(s);
  28.             } else {
  29.                 return slow->classify(s);
  30.             }
  31.         }
  32.     }
  33.  
  34.     ~CombinedClassifier() {
  35.         delete FastClassifier;
  36.         delete MainClassifier;
  37.     }
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement