Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: components/dom_distiller/core/distillable_page_detector.h

Issue 1047223003: Add integration of the new heuristics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dd-adaboost-model
Patch Set: whitelist resources for ios Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "components/dom_distiller/core/proto/adaboost.pb.h" 11 #include "components/dom_distiller/core/proto/adaboost.pb.h"
12 12
13 namespace dom_distiller { 13 namespace dom_distiller {
14 14
15 // DistillablePageDetector provides methods to identify whether or not a page is 15 // DistillablePageDetector provides methods to identify whether or not a page is
16 // likely to be distillable based on a vector of derived features (see 16 // likely to be distillable based on a vector of derived features (see
17 // dom_distiller::CalculateDerivedFeatures). It uses a simple AdaBoost-trained 17 // dom_distiller::CalculateDerivedFeatures). It uses a simple AdaBoost-trained
18 // model. 18 // model.
19 class DistillablePageDetector { 19 class DistillablePageDetector {
20 public: 20 public:
21 static const DistillablePageDetector* GetDefault();
21 explicit DistillablePageDetector(scoped_ptr<AdaBoostProto> proto); 22 explicit DistillablePageDetector(scoped_ptr<AdaBoostProto> proto);
22 ~DistillablePageDetector(); 23 ~DistillablePageDetector();
23 24
24 // Returns true if the model classifies the vector of features as a 25 // Returns true if the model classifies the vector of features as a
25 // distillable page. 26 // distillable page.
26 bool Classify(const std::vector<double>& features) const; 27 bool Classify(const std::vector<double>& features) const;
27 28
28 double Score(const std::vector<double>& features) const; 29 double Score(const std::vector<double>& features) const;
29 double GetThreshold() const; 30 double GetThreshold() const;
30 private: 31 private:
31 scoped_ptr<AdaBoostProto> proto_; 32 scoped_ptr<AdaBoostProto> proto_;
32 double threshold_; 33 double threshold_;
33 DISALLOW_COPY_AND_ASSIGN(DistillablePageDetector); 34 DISALLOW_COPY_AND_ASSIGN(DistillablePageDetector);
34 }; 35 };
35 36
36 37
37 } // namespace dom_distiller 38 } // namespace dom_distiller
38 39
39 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLABLE_PAGE_DETECTOR_H_ 40 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLABLE_PAGE_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698