Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <memory>
- #include "classifiers.h"
- using std::cout;
- using std::string;
- using std::vector;
- class CombinedClassifier {
- private:
- string fast_class, slow_class;
- FastClassifier * fast;
- MainClassifier * slow = nullptr;
- public:
- CombinedClassifier(string& s1, string& s2): fast_class(s1), slow_class(s2) {
- fast = new FastClassifier(fast_class);
- }
- double classify(const string& s) {
- try {
- double ans;
- ans = fast->classify(s);
- return ans;
- } catch (const TooHardObjectException&) {
- if (slow == nullptr) {
- slow = new MainClassifier(slow_class);
- return slow->classify(s);
- } else {
- return slow->classify(s);
- }
- }
- }
- ~CombinedClassifier() {
- delete FastClassifier;
- delete MainClassifier;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement