Bug 1167568 - Find a better topCandidate if there are other nodes scores are high enough, r=Gijs

This commit is contained in:
Evan Tseng 2016-10-07 18:22:05 +08:00
parent 5e9c7a3910
commit 131d923d38
6 changed files with 1825 additions and 24 deletions

View File

@ -1,7 +1,7 @@
language: node_js
sudo: false
node_js:
- '5.3'
- '6.0'
script:
- npm run lint
- npm run test

View File

@ -112,7 +112,7 @@ Readability.prototype = {
// All of the regular expressions in use within readability.
// Defined up here so we don't instantiate them repeatedly in loops.
REGEXPS: {
unlikelyCandidates: /banner|combx|comment|community|cover-wrap|disqus|extra|foot|header|legends|menu|modal|related|remark|rss|shoutbox|sidebar|skyscraper|sponsor|ad-break|agegate|pagination|pager|popup|yom-remote/i,
unlikelyCandidates: /banner|breadcrumbs|combx|comment|community|cover-wrap|disqus|extra|foot|header|legends|menu|modal|related|remark|replies|rss|shoutbox|sidebar|skyscraper|social|sponsor|ad-break|agegate|pagination|pager|popup|yom-remote/i,
okMaybeItsACandidate: /and|article|body|column|main|shadow/i,
positive: /article|body|content|entry|hentry|h-entry|main|page|pagination|post|text|blog|story/i,
negative: /hidden|^hid$| hid$| hid |^hid |banner|combx|comment|com-|contact|foot|footer|footnote|masthead|media|meta|modal|outbrain|promo|related|scroll|share|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i,
@ -844,6 +844,33 @@ Readability.prototype = {
this._initializeNode(topCandidate);
} else if (topCandidate) {
// Find a better top candidate node if it contains (at least three) nodes which belong to `topCandidates` array
// and whose scores are quite closed with current `topCandidate` node.
var alternativeCandidateAncestors = [];
for (var i = 1; i < topCandidates.length; i++) {
if (topCandidates[i].readability.contentScore / topCandidate.readability.contentScore >= 0.75) {
alternativeCandidateAncestors.push(this._getNodeAncestors(topCandidates[i]));
}
}
var MINIMUM_TOPCANDIDATES = 3;
if (alternativeCandidateAncestors.length >= MINIMUM_TOPCANDIDATES) {
parentOfTopCandidate = topCandidate.parentNode;
while (parentOfTopCandidate.tagName !== "BODY") {
var listsContainingThisAncestor = 0;
for (var ancestorIndex = 0; ancestorIndex < alternativeCandidateAncestors.length && listsContainingThisAncestor < MINIMUM_TOPCANDIDATES; ancestorIndex++) {
listsContainingThisAncestor += Number(alternativeCandidateAncestors[ancestorIndex].includes(parentOfTopCandidate));
}
if (listsContainingThisAncestor >= MINIMUM_TOPCANDIDATES) {
topCandidate = parentOfTopCandidate;
break;
}
parentOfTopCandidate = parentOfTopCandidate.parentNode;
}
}
if (!topCandidate.readability) {
this._initializeNode(topCandidate);
}
// Because of our bonus system, parents of candidates might have scores
// themselves. They get half of the node. There won't be nodes with higher
// scores than our topCandidate, but if we see the score going *up* in the first
@ -855,7 +882,11 @@ Readability.prototype = {
var lastScore = topCandidate.readability.contentScore;
// The scores shouldn't get too low.
var scoreThreshold = lastScore / 3;
while (parentOfTopCandidate && parentOfTopCandidate.readability) {
while (parentOfTopCandidate.tagName !== "BODY") {
if (!parentOfTopCandidate.readability) {
parentOfTopCandidate = parentOfTopCandidate.parentNode;
continue;
}
var parentScore = parentOfTopCandidate.readability.contentScore;
if (parentScore < scoreThreshold)
break;

View File

@ -116,27 +116,6 @@
<figcaption class="small caption"> Cloche terrarium (Lucy Akins) </figcaption>
</div>
</div>
<aside class="mod related clearfix" data-module="rcp_bottom">
<h3 class="head headline2 mg-2">More Like This</h3>
<ul class="unstyled">
<li class="item fl ">
<a href="http://www.ehow.com/how_4431062_convert-aquarium-terrarium.html"> <img src="http://img-aws.ehowcdn.com/200x133/cme/photography.prod.demandstudios.com/90f9f3d7-6e4f-4be8-b379-3d994ccbf69c.jpg" class="img" alt=""/>
<p class="headline6 mg-0">How to Convert an Aquarium to a Terrarium</p>
</a>
</li>
<li class="item fl even">
<a href="http://www.ehow.com/video_12263138_plant-terrarium-ideas.html"> <img src="http://img-aws.ehowcdn.com/200x133/viper/media/2b3830ca-4eb6-4bfd-a1cd-d430b3e28d59/jpeg/a7edbb0f-86a7-4c73-9c2d-f85f87b49efa_0.jpg" class="img" alt=""/>
<p class="headline6 mg-0">Plant Terrarium Ideas</p>
</a>
</li>
<li class="item fl ">
<a href="http://www.ehow.com/video_9374_make-terrarium.html"> <img src="http://img-aws.ehowcdn.com/200x133/ehow/images/a00/09/4u/make-terrarium-800x800.jpg" class="img" alt=""/>
<p class="headline6 mg-0">How to Make a Terrarium</p>
</a>
</li>
</ul>
</aside>
<figure id="Comments" class="mod FLC" data-module="comments"> </figure>
<section id="FeaturedTombstone" class="mod" data-module="rcp_tombstone"> </section>
</div>
</div>

View File

@ -0,0 +1,6 @@
{
"title": "How to Throw a Graduation Party on a Budget (with Pictures)",
"byline": "Gina Roberts-Grey",
"excerpt": "How to Throw a Graduation Party on a Budget. Graduation parties are a great way to commemorate the years of hard work teens and college co-eds devote to education. Theyre also costly for mom and dad.The average cost of a graduation party in 2013 was a whopping $1,200, according to Graduationparty.com; $700 of that was allocated for food....",
"readerable": true
}

View File

@ -0,0 +1,164 @@
<div id="readability-page-1" class="page">
<section id="Body" class="InlineTemplate FLC" data-page-id="inlinetemplate" data-section="body">
<header class="page-head bordered pre-col">
<div data-type="AuthorProfile">
<div class="post-meta clearfix headline6 mg-2">
<a class="gtm_contributorBylineAvatar contributor-follow-tip" id="img-follow-tip" href="http://fakehost/contributor/gina_robertsgrey/" target="_top">
<img src="http://img-aws.ehowcdn.com/60x60/cme/cme_public_images/www_demandstudios_com/sitelife.studiod.com/ver1.0/Content/images/store/9/2/d9dd6f61-b183-4893-927f-5b540e45be91.Small.jpg" class="avatar fl" data-failover="//img-aws.ehowcdn.com/60x60/ehow-cdn-assets/test15/media/images/authors/missing-author-image.png" onerror="var failover = this.getAttribute('data-failover');
if (failover) failover = failover.replace(/^https?:/,'');
var src = this.src ? this.src.replace(/^https?:/,'') : '';
if (src != failover){
this.src = failover;
}" /> </a>
</div>
<div class="post-meta clearfix headline6 mg-2" id="author_powertip" data-author-url="/contributor/gina_robertsgrey/">
<a class="gtm_contributorBylineAvatar" href="http://fakehost/contributor/gina_robertsgrey/" target="_top">
<img src="http://img-aws.ehowcdn.com/60x60/cme/cme_public_images/www_demandstudios_com/sitelife.studiod.com/ver1.0/Content/images/store/9/2/d9dd6f61-b183-4893-927f-5b540e45be91.Small.jpg" class="avatar fl" data-failover="//img-aws.ehowcdn.com/60x60/ehow-cdn-assets/test15/media/images/authors/missing-author-image.png" onerror="var failover = this.getAttribute('data-failover');
if (failover) failover = failover.replace(/^https?:/,'');
var src = this.src ? this.src.replace(/^https?:/,'') : '';
if (src != failover){
this.src = failover;
}" /> </a>
<p class="btn btnFollow" data-type="contributor" data-author-url="/contributor/gina_robertsgrey/" data-follow-data="{&quot;name&quot;:&quot;Gina Roberts-Grey&quot;,&quot;slug&quot;:&quot;\/contributor\/gina_robertsgrey\/&quot;,&quot;image_url&quot;:&quot;http:\/\/s3.amazonaws.com\/cme_public_images\/www_demandstudios_com\/sitelife.studiod.com\/ver1.0\/Content\/images\/store\/9\/2\/d9dd6f61-b183-4893-927f-5b540e45be91.Small.jpg&quot;,&quot;website&quot;:&quot;&quot;}">Follow</p>
</div>
<p class="article-meta">
<time datetime="2016-09-14T07:07:00-04:00" itemprop="dateModified">Last updated September 14, 2016</time>
</p>
</div>
</header>
<div class="col-main">
<article data-type="article">
<div class="mod step">
<div class="stepContent mod">
<div class="content lead">
<p>Graduation parties are a great way to commemorate the years of hard work teens and college co-eds devote to education. Theyre also costly for mom and dad.</p>
<p>The average cost of a graduation party in 2013 was a whopping $1,200, according to Graduationparty.com; $700 of that was allocated for food. However that budget was based on Midwestern statistics, and parties in urban areas like New York City are thought to have a much higher price tag.</p>
<p>Thankfully, there are plenty of creative ways to trim a little grad party fat without sacrificing any of the fun or celebratory spirit.</p>
</div>
<figure class="stepThumb">
<img src="http://img-aws.ehowcdn.com/640/cme/cme_public_images/www_ehow_com/cdn-write.demandstudios.com/upload/image/2F/86/5547EF62-EAF5-4256-945D-0496F61C862F/5547EF62-EAF5-4256-945D-0496F61C862F.jpg" alt="Graduation" title="Graduation" class="photo" data-credit="Mike Watson Images/Moodboard/Getty " longdesc="http://s3.amazonaws.com/cme_public_images/www_ehow_com/cdn-write.demandstudios.com/upload/image/2F/86/5547EF62-EAF5-4256-945D-0496F61C862F/5547EF62-EAF5-4256-945D-0496F61C862F.jpg" data-pin-ehow-hover="true" data-pin-no-hover="true" />
</figure>
<figcaption class="small caption">
(Mike Watson Images/Moodboard/Getty)
</figcaption>
</div>
</div>
<span>
<span>
<div class="mod step"><div class="stepContent mod"><div class="content"><span><p>Parties hosted at restaurants, clubhouses and country clubs eliminate the need to spend hours cleaning up once party guests have gone home. But that convenience comes with a price tag. A country club may charge as much as $2,000 for room rental and restaurant food and beverage will almost always cost more than food prepped and served at home.</p></span></div>
<figure class="stepThumb">
<img src="http://img-aws.ehowcdn.com/640/cme/cme_public_images/www_ehow_com/cdn-write.demandstudios.com/upload/image/FE/CB/121569D2-6984-4B2F-83C4-9D2D9A27CBFE/121569D2-6984-4B2F-83C4-9D2D9A27CBFE.jpg" alt="Save money hosting the party at home." class="photo" data-credit="Thomas Jackson/Digital Vision/Getty Images" data-pin-ehow-hover="true" data-pin-no-hover="true" />
</figure>
<figcaption class="small caption">
Thomas Jackson/Digital Vision/Getty Images </figcaption>
</div>
</div>
</span>
</span>
<span>
<span>
<div class="mod step"><div class="stepContent mod"><div class="content"><span><p>Instead of hiring a DJ, use your iPod or Smartphone to spin the tunes. Both easily hook up to most speakers or mp3 compatible docks to play music from your music library. Or download Pandora, the free online radio app, and play hours of music for free.</p>
<p>Personalize the music with a playlist of the grads favorite songs or songs that were big hits during his or her years in school.</p></span></div>
<figure class="stepThumb">
<img src="http://img-aws.ehowcdn.com/640/cme/cme_public_images/www_ehow_com/cdn-write.demandstudios.com/upload/image/DF/FC/A05B0252-BD73-4BC7-A09A-96F0A504FCDF/A05B0252-BD73-4BC7-A09A-96F0A504FCDF.jpg" alt="Online radio can take the place of a hired DJ." class="photo" data-credit="Spencer Platt/Getty Images News/Getty Images" data-pin-ehow-hover="true" data-pin-no-hover="true" />
</figure>
<figcaption class="small caption">
Spencer Platt/Getty Images News/Getty Images </figcaption>
</div>
</div>
</span>
</span>
<span>
<span>
<div class="mod step"><div class="stepContent mod"><div class="content"><span><p>Avoid canned drinks, which guests often open, but don't finish. Serve pitchers of tap water with lemon and cucumber slices or sliced strawberries for an interesting and refreshing flavor. Opt for punches and non-alcoholic drinks for high school graduates that allow guests to dole out the exact amount they want to drink.</p></span></div>
<figure class="stepThumb">
<img src="http://img-aws.ehowcdn.com/640/cme/cme_public_images/www_ehow_com/cdn-write.demandstudios.com/upload/image/EB/DB/8A04CCA7-3255-4225-B59A-C41441F8DBEB/8A04CCA7-3255-4225-B59A-C41441F8DBEB.jpg" alt="Serve drinks in pitchers, not in cans." class="photo" data-credit="evgenyb/iStock/Getty Images" data-pin-ehow-hover="true" data-pin-no-hover="true" />
</figure>
<figcaption class="small caption">
evgenyb/iStock/Getty Images </figcaption>
</div>
</div>
</span>
</span>
<span>
<span>
<div class="mod step"><div class="stepContent mod"><div class="content"><span><p>Instead of inviting everyone you and the graduate know or ever knew, scale back the guest list. Forgo inviting guests that you or your grad haven't seen for eons. There is no reason to provide provisions for people who are essentially out of your lives. Sticking to a small, but personal, guest list allows more time to mingle with loved ones during the party, too.</p></span></div>
<figure class="stepThumb">
<img src="http://img-aws.ehowcdn.com/640/cme/cme_public_images/www_ehow_com/cdn-write.demandstudios.com/upload/image/94/10/08035476-0167-4A03-AADC-13A7E7AA1094/08035476-0167-4A03-AADC-13A7E7AA1094.jpg" alt="Limit guests to those close to the graduate." class="photo" data-credit="Kane Skennar/Photodisc/Getty Images" data-pin-ehow-hover="true" data-pin-no-hover="true" />
</figure>
<figcaption class="small caption">
Kane Skennar/Photodisc/Getty Images </figcaption>
</div>
</div>
</span>
</span>
<span>
<span>
<div class="mod step"><div class="stepContent mod"><div class="content"><span><p>See if your grad and his best friend, girlfriend or close family member would consider hosting a joint party. You can split some of the expenses, especially when the two graduates share mutual friends. You'll also have another parent to bounce ideas off of and to help you stick to your budget when you're tempted to splurge.</p></span></div>
<figure class="stepThumb">
<img src="http://img-aws.ehowcdn.com/640/cme/cme_public_images/www_ehow_com/cdn-write.demandstudios.com/upload/image/06/49/4AD62696-FC95-4DA2-8351-42740C7B4906/4AD62696-FC95-4DA2-8351-42740C7B4906.jpg" alt="Throw a joint bash for big savings." class="photo" data-credit="Mike Watson Images/Moodboard/Getty" data-pin-ehow-hover="true" data-pin-no-hover="true" />
</figure>
<figcaption class="small caption">
Mike Watson Images/Moodboard/Getty </figcaption>
</div>
</div>
</span>
</span>
<span>
<span>
<div class="mod step"><div class="stepContent mod"><div class="content"><span><p>Skip carving stations of prime rib and jumbo shrimp as appetizers, especially for high school graduation parties. Instead, serve some of the graduate's favorite side dishes that are cost effective, like a big pot of spaghetti with breadsticks. Opt for easy and simple food such as pizza, finger food and mini appetizers. </p>
<p>Avoid pre-packaged foods and pre-made deli platters. These can be quite costly. Instead, make your own cheese and deli platters for less than half the cost of pre-made.</p></span></div>
<figure class="stepThumb">
<img src="http://img-aws.ehowcdn.com/640/cme/cme_public_images/www_ehow_com/cdn-write.demandstudios.com/upload/image/D0/51/B6AED06C-5E19-4A26-9AAD-0E175F6251D0/B6AED06C-5E19-4A26-9AAD-0E175F6251D0.jpg" alt="Cost effective appetizers are just as satisfying as pre-made deli platters." class="photo" data-credit="Mark Stout/iStock/Getty Images" data-pin-ehow-hover="true" data-pin-no-hover="true" />
</figure>
<figcaption class="small caption">
Mark Stout/iStock/Getty Images </figcaption>
</div>
</div>
</span>
</span>
<span>
<span>
<div class="mod step"><div class="stepContent mod"><div class="content"><span><p>Instead of an evening dinner party, host a grad lunch or all appetizers party. Brunch and lunch fare or finger food costs less than dinner. Guests also tend to consume less alcohol in the middle of the day, which keeps cost down.</p></span></div>
<figure class="stepThumb">
<img src="http://img-aws.ehowcdn.com/640/cme/cme_public_images/www_ehow_com/cdn-write.demandstudios.com/upload/image/35/B4/DD5FD05A-B631-4AFE-BC8F-FDACAD1EB435/DD5FD05A-B631-4AFE-BC8F-FDACAD1EB435.jpg" alt="A brunch gathering will cost less than a dinner party." class="photo" data-credit="Mark Stout/iStock/Getty Images" data-pin-ehow-hover="true" data-pin-no-hover="true" />
</figure>
<figcaption class="small caption">
Mark Stout/iStock/Getty Images </figcaption>
</div>
</div>
</span>
</span>
<span>
<span>
<div class="mod step"><div class="stepContent mod"><div class="content"><span><p>Decorate your party in the graduate's current school colors or the colors of the school he or she will be headed to next. Décor that is not specifically graduation-themed may cost a bit less, and any leftovers can be re-used for future parties, picnics and events.</p></span></div>
<figure class="stepThumb">
<img src="http://img-aws.ehowcdn.com/640/cme/cme_public_images/www_ehow_com/cdn-write.demandstudios.com/upload/image/A1/FA/2C368B34-8F6A-45F6-9DFC-0B0C4E33FAA1/2C368B34-8F6A-45F6-9DFC-0B0C4E33FAA1.jpg" alt="Theme the party by color without graduation-specific decor." class="photo" data-credit="jethuynh/iStock/Getty Images" data-pin-ehow-hover="true" data-pin-no-hover="true" />
</figure>
<figcaption class="small caption">
jethuynh/iStock/Getty Images </figcaption>
</div>
</div>
</span>
</span>
<h2 class="RsTitle head mg-2 title">
<a target="_blank" href="https://www.google.com/adsense/support/bin/request.py?contact=abg_afc&amp;url=http://ehow.com/&amp;hl=en&amp;client=ehow&amp;gl=US">Related Searches</a>
</h2>
<p class="zergnet-pw">Promoted By Zergnet</p>
</article>
</div>
</section>
</div>

File diff suppressed because it is too large Load Diff