| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLABLE_PAGE_DETECTOR_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLABLE_PAGE_DETECTOR_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CORE_DISTILLABLE_PAGE_DETECTOR_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CORE_DISTILLABLE_PAGE_DETECTOR_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "components/dom_distiller/core/proto/adaboost.pb.h" | 12 #include "components/dom_distiller/core/proto/adaboost.pb.h" |
| 13 | 13 |
| 14 namespace dom_distiller { | 14 namespace dom_distiller { |
| 15 | 15 |
| 16 // DistillablePageDetector provides methods to identify whether or not a page is | 16 // DistillablePageDetector provides methods to identify whether or not a page is |
| 17 // likely to be distillable based on a vector of derived features (see | 17 // likely to be distillable based on a vector of derived features (see |
| 18 // dom_distiller::CalculateDerivedFeatures). It uses a simple AdaBoost-trained | 18 // dom_distiller::CalculateDerivedFeatures). It uses a simple AdaBoost-trained |
| 19 // model. | 19 // model. |
| 20 class DistillablePageDetector { | 20 class DistillablePageDetector { |
| 21 public: | 21 public: |
| 22 static const DistillablePageDetector* GetDefault(); | 22 static const DistillablePageDetector* GetDefault(); |
| 23 static const DistillablePageDetector* GetNewModel(); | 23 static const DistillablePageDetector* GetNewModel(); |
| 24 static const DistillablePageDetector* GetLongPageModel(); | 24 static const DistillablePageDetector* GetLongPageModel(); |
| 25 explicit DistillablePageDetector(scoped_ptr<AdaBoostProto> proto); | 25 explicit DistillablePageDetector(std::unique_ptr<AdaBoostProto> proto); |
| 26 ~DistillablePageDetector(); | 26 ~DistillablePageDetector(); |
| 27 | 27 |
| 28 // Returns true if the model classifies the vector of features as a | 28 // Returns true if the model classifies the vector of features as a |
| 29 // distillable page. | 29 // distillable page. |
| 30 bool Classify(const std::vector<double>& features) const; | 30 bool Classify(const std::vector<double>& features) const; |
| 31 | 31 |
| 32 double Score(const std::vector<double>& features) const; | 32 double Score(const std::vector<double>& features) const; |
| 33 double GetThreshold() const; | 33 double GetThreshold() const; |
| 34 private: | 34 private: |
| 35 scoped_ptr<AdaBoostProto> proto_; | 35 std::unique_ptr<AdaBoostProto> proto_; |
| 36 double threshold_; | 36 double threshold_; |
| 37 DISALLOW_COPY_AND_ASSIGN(DistillablePageDetector); | 37 DISALLOW_COPY_AND_ASSIGN(DistillablePageDetector); |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 | 40 |
| 41 } // namespace dom_distiller | 41 } // namespace dom_distiller |
| 42 | 42 |
| 43 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLABLE_PAGE_DETECTOR_H_ | 43 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLABLE_PAGE_DETECTOR_H_ |
| OLD | NEW |