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

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: whitelist resources for ios 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 057adbf924fad00b3c3c57a5edef0c236698722e..05405886a01fc33dbd2fbc63fb63f71e4f5b009e 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>();
« no previous file with comments | « components/dom_distiller/core/page_features.h ('k') | components/dom_distiller/core/page_features_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698