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 +4 -4
- data/lib/detergent/content_locator.rb +10 -0
- data/lib/detergent/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e00871e3ab04f35424e5c563328b1e036bf14a10ec9738da79c81462135e963
|
|
4
|
+
data.tar.gz: b600be23e126d45cdfcc8e058398a1096274693be3d985f3051511e718f7c248
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/detergent/version.rb
CHANGED