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 #include "components/dom_distiller/core/distillable_page_detector.h" | 5 #include "components/dom_distiller/core/distillable_page_detector.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace dom_distiller { | 10 namespace dom_distiller { |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 std::unique_ptr<DistillablePageDetector> Build() { | 25 std::unique_ptr<DistillablePageDetector> Build() { |
26 int num_features = 0; | 26 int num_features = 0; |
27 for (int i = 0; i < proto_.stump_size(); ++i) { | 27 for (int i = 0; i < proto_.stump_size(); ++i) { |
28 num_features = | 28 num_features = |
29 std::max(num_features, proto_.stump(i).feature_number() + 1); | 29 std::max(num_features, proto_.stump(i).feature_number() + 1); |
30 } | 30 } |
31 proto_.set_num_features(num_features); | 31 proto_.set_num_features(num_features); |
32 proto_.set_num_stumps(proto_.stump_size()); | 32 proto_.set_num_stumps(proto_.stump_size()); |
33 return base::WrapUnique(new DistillablePageDetector( | 33 return base::MakeUnique<DistillablePageDetector>( |
34 base::WrapUnique(new AdaBoostProto(proto_)))); | 34 base::WrapUnique(new AdaBoostProto(proto_))); |
35 } | 35 } |
36 | 36 |
37 private: | 37 private: |
38 AdaBoostProto proto_; | 38 AdaBoostProto proto_; |
39 }; | 39 }; |
40 | 40 |
41 } | 41 } |
42 | 42 |
43 TEST(DomDistillerDistillablePageDetectorTest, TestCalculateThreshold) { | 43 TEST(DomDistillerDistillablePageDetectorTest, TestCalculateThreshold) { |
44 std::unique_ptr<DistillablePageDetector> detector = | 44 std::unique_ptr<DistillablePageDetector> detector = |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 std::vector<double> features; | 100 std::vector<double> features; |
101 EXPECT_DOUBLE_EQ(0.0, detector->Score(features)); | 101 EXPECT_DOUBLE_EQ(0.0, detector->Score(features)); |
102 features.push_back(-3.0); | 102 features.push_back(-3.0); |
103 features.push_back(1.0); | 103 features.push_back(1.0); |
104 EXPECT_DOUBLE_EQ(0.0, detector->Score(features)); | 104 EXPECT_DOUBLE_EQ(0.0, detector->Score(features)); |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 } | 108 } |
109 | 109 |
OLD | NEW |