Skip to content

Commit

Permalink
Some tinkering with values
Browse files Browse the repository at this point in the history
  • Loading branch information
skid committed Mar 15, 2012
1 parent 82db8cd commit 38d7a87
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions extractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ function analyze(dom, options){
node.textNodes += 1;
}
}
node.avgScore = (total + node.score) / ((node.nodes || 0) + 1);
node.avgScore = (total + (node.score || 0)) / ((node.nodes || 0) + 1);

return total;
})(bodyNode);
Expand Down Expand Up @@ -691,7 +691,9 @@ function analyze(dom, options){
* If the winner contains relatively few direct children, the content is probably inside one of them.
* We check this by looking at the directChildren / totalTextNodes ratio.
**/

var wnode, rnode;
printTree(winner)
while(winner.children.length / winner.textNodes < 0.1){
wnode = rnode = null;
winner.children.forEach(function(child){
Expand All @@ -714,7 +716,12 @@ function analyze(dom, options){
}
});
}
winner = wnode;
if(wnode && wnode.words/winner.words > 0.1){
winner = wnode;
}
else {
break;
}
}

/**
Expand Down

0 comments on commit 38d7a87

Please sign in to comment.