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

Side by Side Diff: components/dom_distiller/content/renderer/distillability_agent.cc

Issue 2021643002: Record scores of distillability and long article in UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@distillability-dev
Patch Set: add comments Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/metrics/histogram.h" 5 #include "base/metrics/histogram.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 7
8 #include "components/dom_distiller/content/common/distillability_service.mojom.h " 8 #include "components/dom_distiller/content/common/distillability_service.mojom.h "
9 #include "components/dom_distiller/content/renderer/distillability_agent.h" 9 #include "components/dom_distiller/content/renderer/distillability_agent.h"
10 #include "components/dom_distiller/core/distillable_page_detector.h" 10 #include "components/dom_distiller/core/distillable_page_detector.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 std::vector<double> derived = CalculateDerivedFeatures( 86 std::vector<double> derived = CalculateDerivedFeatures(
87 features.openGraph, 87 features.openGraph,
88 parsed_url, 88 parsed_url,
89 features.elementCount, 89 features.elementCount,
90 features.anchorCount, 90 features.anchorCount,
91 features.formCount, 91 features.formCount,
92 features.mozScore, 92 features.mozScore,
93 features.mozScoreAllSqrt, 93 features.mozScoreAllSqrt,
94 features.mozScoreAllLinear 94 features.mozScoreAllLinear
95 ); 95 );
96 bool distillable = detector->Classify(derived); 96 double score = detector->Score(derived) - detector->GetThreshold();
97 bool long_article = long_page->Classify(derived); 97 double long_score = long_page->Score(derived) - long_page->GetThreshold();
98 bool distillable = score > 0;
99 bool long_article = long_score > 0;
98 bool blacklisted = IsBlacklisted(parsed_url); 100 bool blacklisted = IsBlacklisted(parsed_url);
99 101
102 if (!features.isMobileFriendly) {
103 int score_int = std::round(score * 100);
104 if (score > 0) {
105 UMA_HISTOGRAM_COUNTS_1000("DomDistiller.DistillabilityScoreNMF.Positive",
106 score_int);
107 } else {
108 UMA_HISTOGRAM_COUNTS_1000("DomDistiller.DistillabilityScoreNMF.Negative",
109 -score_int);
110 }
111 if (distillable) {
112 // The long-article model is trained with pages that are
113 // non-mobile-friendly, and distillable (deemed by the first model), so
114 // only record on that type of pages.
115 int long_score_int = std::round(long_score * 100);
116 if (long_score > 0) {
117 UMA_HISTOGRAM_COUNTS_1000("DomDistiller.LongArticleScoreNMF.Positive",
118 long_score_int);
119 } else {
120 UMA_HISTOGRAM_COUNTS_1000("DomDistiller.LongArticleScoreNMF.Negative",
121 -long_score_int);
122 }
123 }
124 }
125
100 int bucket = static_cast<unsigned>(features.isMobileFriendly) | 126 int bucket = static_cast<unsigned>(features.isMobileFriendly) |
101 (static_cast<unsigned>(distillable) << 1); 127 (static_cast<unsigned>(distillable) << 1);
102 if (is_last) { 128 if (is_last) {
103 UMA_HISTOGRAM_ENUMERATION("DomDistiller.PageDistillableAfterLoading", 129 UMA_HISTOGRAM_ENUMERATION("DomDistiller.PageDistillableAfterLoading",
104 bucket, 4); 130 bucket, 4);
105 } else { 131 } else {
106 UMA_HISTOGRAM_ENUMERATION("DomDistiller.PageDistillableAfterParsing", 132 UMA_HISTOGRAM_ENUMERATION("DomDistiller.PageDistillableAfterParsing",
107 bucket, 4); 133 bucket, 4);
108 if (!distillable) { 134 if (!distillable) {
109 UMA_HISTOGRAM_ENUMERATION("DomDistiller.DistillabilityRejection", 135 UMA_HISTOGRAM_ENUMERATION("DomDistiller.DistillabilityRejection",
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 render_frame()->GetServiceRegistry()->ConnectToRemoteService( 204 render_frame()->GetServiceRegistry()->ConnectToRemoteService(
179 mojo::GetProxy(&distillability_service)); 205 mojo::GetProxy(&distillability_service));
180 DCHECK(distillability_service); 206 DCHECK(distillability_service);
181 distillability_service->NotifyIsDistillable( 207 distillability_service->NotifyIsDistillable(
182 IsDistillablePage(doc, is_last), is_last); 208 IsDistillablePage(doc, is_last), is_last);
183 } 209 }
184 210
185 DistillabilityAgent::~DistillabilityAgent() {} 211 DistillabilityAgent::~DistillabilityAgent() {}
186 212
187 } // namespace dom_distiller 213 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698