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

Unified Diff: components/dom_distiller/core/page_features.cc

Issue 1047223003: Add integration of the new heuristics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dd-adaboost-model
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: components/dom_distiller/core/page_features.cc
diff --git a/components/dom_distiller/core/page_features.cc b/components/dom_distiller/core/page_features.cc
index 6b1e5af7c9dc1ca1b1da09b48cb32f8d42627b6f..11c2db573203952c0a03cfcd277ee8ab71715e19 100644
--- a/components/dom_distiller/core/page_features.cc
+++ b/components/dom_distiller/core/page_features.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/json/json_reader.h"
#include "third_party/re2/re2/re2.h"
namespace dom_distiller {
@@ -47,6 +48,8 @@ bool EndsWith(const std::string& t, const std::string& s) {
}
}
+int kDerivedFeaturesCount = 29;
+
std::vector<double> CalculateDerivedFeatures(bool isOGArticle,
const GURL& url,
double numElements,
@@ -132,7 +135,18 @@ std::vector<double> CalculateDerivedFeatures(bool isOGArticle,
return features;
}
-std::vector<double> CalculateDerivedFeaturesFromJSON(const base::Value* json) {
+std::vector<double> CalculateDerivedFeaturesFromJSON(
+ const base::Value* stringified_json) {
+ std::string stringified;
+ if (!stringified_json->GetAsString(&stringified)) {
+ return std::vector<double>();
+ }
+
+ scoped_ptr<base::Value> json(base::JSONReader::Read(stringified));
+ if (!json) {
+ return std::vector<double>();
+ }
+
const base::DictionaryValue* dict;
if (!json->GetAsDictionary(&dict)) {
return std::vector<double>();

Powered by Google App Engine
This is Rietveld 408576698