detergent 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e2a63a0bf0f9524e9d7e4c1b873d2cb0eab8e29873bad005c1545501fa9915a
4
- data.tar.gz: 03f8f53ce63ffa717b8b5d0981d92a02b307a466393ac9e37299d66e18dcdda8
3
+ metadata.gz: 1e00871e3ab04f35424e5c563328b1e036bf14a10ec9738da79c81462135e963
4
+ data.tar.gz: b600be23e126d45cdfcc8e058398a1096274693be3d985f3051511e718f7c248
5
5
  SHA512:
6
- metadata.gz: 5963938b39385d4935e6080ce5b4256996f352d8582976edf8b7a95f73fbe5a896bca8e282dcdfce4b62768e4488ddef0f354706bacab04f9cb69d9ea7120b3c
7
- data.tar.gz: 17391d9c496d0fe55dff25f68fd85e63c2ed3b391db05c1c714c6cce2250c457dc48a5b8f0b2d4a5cf3de19295317cd3eeba9b9b29d83547e990cec2cdf577c5
6
+ metadata.gz: 5263b607e0e15a25b15ab1df4c846f5228a7c188daf6a78811a67e91bf06fdc46b2b9e188fc4158657223e8665df5de894e3b1a6611be5886ab2489c7d63210c
7
+ data.tar.gz: '0884b42ce893b34ff696234b0d094d9a0a8613c5d9eee3b979308c9214eb4a0b67b5247a9b7cb33e0af9e9320922995dd234c5844e0e3169e899da4e6ab687fe'
@@ -11,13 +11,23 @@ module Detergent
11
11
  # promoted — not just score marginally higher from including the child.
12
12
  PARENT_PROMOTION_RATIO = 1.3
13
13
 
14
+ # If even the best-scoring node falls below this, the page has no main
15
+ # content to extract. Pages made entirely of links (index pages, link
16
+ # aggregators like the Hacker News front page) score at or near zero
17
+ # everywhere, and without a floor a degenerate winner gets elected —
18
+ # e.g. a logo cell that picked up a few points for containing an image.
19
+ MINIMUM_CONTENT_SCORE = 25
20
+
14
21
  def initialize(scorer)
15
22
  @scorer = scorer
16
23
  end
17
24
 
25
+ # Returns the main content root node, or nil if the page doesn't
26
+ # appear to have main content at all.
18
27
  def locate(body)
19
28
  highest_scoring = find_highest_scoring_node(body)
20
29
  return nil unless highest_scoring
30
+ return nil if score(highest_scoring) < MINIMUM_CONTENT_SCORE
21
31
 
22
32
  find_content_root(highest_scoring)
23
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Detergent
4
- VERSION = "2.1.0"
4
+ VERSION = "2.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: detergent
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff McFadden