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

Side by Side Diff: heuristics/distillable/extract_features.js

Issue 1809473003: Decrease mismatches in feature extraction (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 return (function() { 1 return (function() {
2 function hasOGArticle() { 2 function hasOGArticle() {
3 var elems = document.head.querySelectorAll( 3 var elems = document.head.querySelectorAll(
4 'meta[property="og:type"],meta[name="og:type"]'); 4 'meta[property="og:type"],meta[name="og:type"]');
5 for (var i in elems) { 5 for (var i in elems) {
6 if (elems[i].content && elems[i].content.toUpperCase() == 'ARTICLE') { 6 if (elems[i].content && elems[i].content.toUpperCase() == 'ARTICLE') {
7 return true; 7 return true;
8 } 8 }
9 } 9 }
10 return false; 10 return false;
11 } 11 }
12 12
13 function isVisible(e) { 13 function isVisible(e) {
14 var bounds = e.getBoundingClientRect() 14 var bounds = e.getBoundingClientRect()
15 var style = window.getComputedStyle(e); 15 var style = window.getComputedStyle(e);
16 return !( 16 return !(
17 bounds.height == 0 || bounds.width == 0 || 17 (bounds.height == 0 && bounds.width == 0) ||
18 style.display == "none" || 18 style.display == "none" ||
19 style.visibility == "hidden" || 19 style.visibility == "hidden" ||
20 style.opacity == 0 20 style.opacity == 0
21 ) 21 )
22 } 22 }
23 23
24 function countVisible(nodes) { 24 function countVisible(nodes) {
25 var count = 0; 25 var count = 0;
26 for (var i = 0; i < nodes.length; i++) { 26 for (var i = 0; i < nodes.length; i++) {
27 var node = nodes[i]; 27 var node = nodes[i];
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 'mozScore': _mozScore(true, 0.5, 140, true, 1e100), 89 'mozScore': _mozScore(true, 0.5, 140, true, 1e100),
90 'mozScoreAllSqrt': _mozScore(true, 0.5, 0, true, 1e100), 90 'mozScoreAllSqrt': _mozScore(true, 0.5, 0, true, 1e100),
91 'mozScoreAllLinear': _mozScore(true, 1, 0, true, 1e100), 91 'mozScoreAllLinear': _mozScore(true, 1, 0, true, 1e100),
92 'mozScoreFast': _mozScore(false, 0.5, 140, true, 1000), 92 'mozScoreFast': _mozScore(false, 0.5, 140, true, 1000),
93 'mozScoreFastAllSqrt': _mozScore(false, 0.5, 0, true, 1000), 93 'mozScoreFastAllSqrt': _mozScore(false, 0.5, 0, true, 1000),
94 'mozScoreFastAllLinear': _mozScore(false, 1, 0, true, 1000), 94 'mozScoreFastAllLinear': _mozScore(false, 1, 0, true, 1000),
95 'visibleElements': countVisible(body.querySelectorAll('*')), 95 'visibleElements': countVisible(body.querySelectorAll('*')),
96 'visiblePPRE': countVisible(body.querySelectorAll('p,pre')), 96 'visiblePPRE': countVisible(body.querySelectorAll('p,pre')),
97 } 97 }
98 })() 98 })()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698