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>(); |