Chromium Code Reviews| Index: components/dom_distiller/core/distillable_page_detector.cc |
| diff --git a/components/dom_distiller/core/distillable_page_detector.cc b/components/dom_distiller/core/distillable_page_detector.cc |
| index 8980aebd45c777eea8580912fe134259c1f4c0aa..db0392b6655b7699ab9ce2b34624be660773c812 100644 |
| --- a/components/dom_distiller/core/distillable_page_detector.cc |
| +++ b/components/dom_distiller/core/distillable_page_detector.cc |
| @@ -5,9 +5,25 @@ |
| #include "components/dom_distiller/core/distillable_page_detector.h" |
| #include "base/logging.h" |
| +#include "grit/components_resources.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| namespace dom_distiller { |
| +const DistillablePageDetector* DistillablePageDetector::GetDefault() { |
| + static DistillablePageDetector* detector = nullptr; |
| + if (!detector) { |
| + std::string serialized_proto = |
| + ResourceBundle::GetSharedInstance() |
| + .GetRawDataResource(IDR_DISTILLABLE_PAGE_SERIALIZED_MODEL) |
| + .as_string(); |
| + scoped_ptr<AdaBoostProto> proto(new AdaBoostProto); |
| + CHECK(proto->ParseFromString(serialized_proto)); |
| + detector = new DistillablePageDetector(proto.Pass()); |
| + } |
| + return detector; |
| +} |
| + |
| DistillablePageDetector::DistillablePageDetector( |
| scoped_ptr<AdaBoostProto> proto) |
| : proto_(proto.Pass()), threshold_(0.0) { |
| @@ -29,7 +45,9 @@ bool DistillablePageDetector::Classify( |
| double DistillablePageDetector::Score( |
| const std::vector<double>& features) const { |
| - CHECK(features.size() == size_t(proto_->num_features())); |
| + if (features.size() != size_t(proto_->num_features())) { |
|
nyquist
2015/04/01 18:12:20
I would be OK with moving this to your previous CL
cjhopman
2015/04/01 20:59:29
Done.
|
| + return 0.0; |
| + } |
| double score = 0.0; |
| for (int i = 0; i < proto_->num_stumps(); ++i) { |
| const StumpProto& stump = proto_->stump(i); |