Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include "classifiers.h"
  2. #include <memory>
  3.  
  4. class CombinedClassifier {
  5. private:
  6. std::unique_ptr<MainClassifier> p1;
  7. std::unique_ptr<FastClassifier> p2;
  8. std::string str;
  9. public:
  10. CombinedClassifier(const std::string& s1, const std::string& s2) {
  11. p1.reset(new MainClassifier(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 == nullptr) {
  20. p2.reset(new FastClassifier(str));
  21. }
  22. return p2->classify(s);
  23. }
  24. }
  25. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement