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/page_features.h" | 5 #include "components/dom_distiller/core/page_features.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "third_party/re2/src/re2/re2.h" | 13 #include "third_party/re2/src/re2/re2.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 namespace dom_distiller { | 16 namespace dom_distiller { |
17 /* This code needs to derive features in the same way and order in which they | 17 /* This code needs to derive features in the same way and order in which they |
18 * are derived when training the model. Parts of that code are reproduced in the | 18 * are derived when training the model. Parts of that code are reproduced in the |
19 * comments below. | 19 * comments below. |
20 */ | 20 */ |
21 | 21 |
22 namespace { | 22 namespace { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return features; | 145 return features; |
146 } | 146 } |
147 | 147 |
148 std::vector<double> CalculateDerivedFeaturesFromJSON( | 148 std::vector<double> CalculateDerivedFeaturesFromJSON( |
149 const base::Value* stringified_json) { | 149 const base::Value* stringified_json) { |
150 std::string stringified; | 150 std::string stringified; |
151 if (!stringified_json->GetAsString(&stringified)) { | 151 if (!stringified_json->GetAsString(&stringified)) { |
152 return std::vector<double>(); | 152 return std::vector<double>(); |
153 } | 153 } |
154 | 154 |
155 scoped_ptr<base::Value> json = base::JSONReader::Read(stringified); | 155 std::unique_ptr<base::Value> json = base::JSONReader::Read(stringified); |
156 if (!json) { | 156 if (!json) { |
157 return std::vector<double>(); | 157 return std::vector<double>(); |
158 } | 158 } |
159 | 159 |
160 const base::DictionaryValue* dict; | 160 const base::DictionaryValue* dict; |
161 if (!json->GetAsDictionary(&dict)) { | 161 if (!json->GetAsDictionary(&dict)) { |
162 return std::vector<double>(); | 162 return std::vector<double>(); |
163 } | 163 } |
164 | 164 |
165 bool isOGArticle = false; | 165 bool isOGArticle = false; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 features.push_back(mozScore); | 241 features.push_back(mozScore); |
242 // 'mozScoreAllSqrt' | 242 // 'mozScoreAllSqrt' |
243 features.push_back(mozScoreAllSqrt); | 243 features.push_back(mozScoreAllSqrt); |
244 // 'mozScoreAllLinear' | 244 // 'mozScoreAllLinear' |
245 features.push_back(mozScoreAllLinear); | 245 features.push_back(mozScoreAllLinear); |
246 | 246 |
247 return features; | 247 return features; |
248 } | 248 } |
249 | 249 |
250 } // namespace dom_distiller | 250 } // namespace dom_distiller |
OLD | NEW |