| 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_PAGE_FEATURES_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_PAGE_FEATURES_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CORE_PAGE_FEATURES_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CORE_PAGE_FEATURES_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 class GURL; |
| 14 |
| 15 namespace blink { |
| 16 struct WebDistillabilityFeatures; |
| 17 } |
| 18 |
| 13 namespace dom_distiller { | 19 namespace dom_distiller { |
| 14 | 20 |
| 15 // The length of the derived features vector. | 21 // The length of the derived features vector. |
| 16 extern int kDerivedFeaturesCount; | 22 extern int kDerivedFeaturesCount; |
| 17 | 23 |
| 18 // The distillable page detector is a model trained on a list of numeric | 24 // The distillable page detector is a model trained on a list of numeric |
| 19 // features derived from core more complex features of a webpage (like the | 25 // features derived from features of a webpage (like body's number of elements |
| 20 // body's .textContent). This derives the numeric features for a set of core | 26 // ). This derives the numeric features form a set of core features. |
| 21 // features. | |
| 22 // | 27 // |
| 23 // Note: It is crucial that these features are derived in the same way and are | 28 // Note: It is crucial that these features are derived in the same way and are |
| 24 // in the same order as in the training pipeline. See //heuristics/distillable | 29 // in the same order as in the training pipeline. See //heuristics/distillable |
| 25 // in the external DomDistillerJs repo. | 30 // in the external DomDistiller repo. |
| 26 std::vector<double> CalculateDerivedFeatures(bool isOGArticle, | 31 std::vector<double> CalculateDerivedFeatures(bool isOGArticle, |
| 27 const GURL& url, | 32 const GURL& url, |
| 28 double numElements, | 33 double numElements, |
| 29 double numAnchors, | 34 double numAnchors, |
| 30 double numForms, | 35 double numForms, |
| 31 const std::string& innerText, | 36 const std::string& innerText, |
| 32 const std::string& textContent, | 37 const std::string& textContent, |
| 33 const std::string& innerHTML); | 38 const std::string& innerHTML); |
| 34 | 39 |
| 35 // Calculates the derived features from the JSON value as returned by the | 40 // Calculates the derived features from the JSON value as returned by the |
| 36 // javascript core feature extraction. | 41 // javascript core feature extraction. |
| 37 std::vector<double> CalculateDerivedFeaturesFromJSON( | 42 std::vector<double> CalculateDerivedFeaturesFromJSON( |
| 38 const base::Value* stringified_json); | 43 const base::Value* stringified_json); |
| 39 | 44 |
| 45 std::vector<double> CalculateDerivedFeatures( |
| 46 const blink::WebDistillabilityFeatures& f, |
| 47 const GURL& url); |
| 48 |
| 40 } // namespace dom_distiller | 49 } // namespace dom_distiller |
| 41 | 50 |
| 42 #endif // COMPONENTS_DOM_DISTILLER_CORE_PAGE_FEATURES_H_ | 51 #endif // COMPONENTS_DOM_DISTILLER_CORE_PAGE_FEATURES_H_ |
| OLD | NEW |