Class: Html2rss::AutoSource::LinkHeuristics::ContainerSignals
- Inherits:
-
Data
- Object
- Data
- Html2rss::AutoSource::LinkHeuristics::ContainerSignals
- Defined in:
- lib/html2rss/auto_source/link_heuristics/container_signals.rb
Overview
Container observations used to compute quality/junk scores.
Instance Attribute Summary collapse
-
#article_container ⇒ Object
readonly
Returns the value of attribute article_container.
-
#content_path ⇒ Object
readonly
Returns the value of attribute content_path.
-
#content_tokens ⇒ Object
readonly
Returns the value of attribute content_tokens.
-
#descriptive_context ⇒ Object
readonly
Returns the value of attribute descriptive_context.
-
#high_confidence_junk_path ⇒ Object
readonly
Returns the value of attribute high_confidence_junk_path.
-
#high_confidence_utility_destination ⇒ Object
readonly
Returns the value of attribute high_confidence_utility_destination.
-
#junk_tokens ⇒ Object
readonly
Returns the value of attribute junk_tokens.
-
#path_length ⇒ Object
readonly
Returns the value of attribute path_length.
-
#publish_marker ⇒ Object
readonly
Returns the value of attribute publish_marker.
-
#recommended_title ⇒ Object
readonly
Returns the value of attribute recommended_title.
-
#selected_anchor_present ⇒ Object
readonly
Returns the value of attribute selected_anchor_present.
-
#shallow ⇒ Object
readonly
Returns the value of attribute shallow.
-
#strong_post_suffix ⇒ Object
readonly
Returns the value of attribute strong_post_suffix.
-
#title_word_count ⇒ Object
readonly
Returns the value of attribute title_word_count.
-
#utility_path ⇒ Object
readonly
Returns the value of attribute utility_path.
-
#utility_prefix_title ⇒ Object
readonly
Returns the value of attribute utility_prefix_title.
Instance Method Summary collapse
-
#final_score ⇒ Integer
Quality minus junk for stable ranking.
-
#hard_junk? ⇒ Boolean
True when the entry should be dropped before ranking.
-
#junk_score ⇒ Integer
Junk penalty subtracted from quality.
-
#quality_score ⇒ Integer
Positive quality contribution for ranking.
Instance Attribute Details
#article_container ⇒ Object (readonly)
Returns the value of attribute article_container
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def article_container @article_container end |
#content_path ⇒ Object (readonly)
Returns the value of attribute content_path
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def content_path @content_path end |
#content_tokens ⇒ Object (readonly)
Returns the value of attribute content_tokens
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def content_tokens @content_tokens end |
#descriptive_context ⇒ Object (readonly)
Returns the value of attribute descriptive_context
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def descriptive_context @descriptive_context end |
#high_confidence_junk_path ⇒ Object (readonly)
Returns the value of attribute high_confidence_junk_path
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def high_confidence_junk_path @high_confidence_junk_path end |
#high_confidence_utility_destination ⇒ Object (readonly)
Returns the value of attribute high_confidence_utility_destination
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def high_confidence_utility_destination @high_confidence_utility_destination end |
#junk_tokens ⇒ Object (readonly)
Returns the value of attribute junk_tokens
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def junk_tokens @junk_tokens end |
#path_length ⇒ Object (readonly)
Returns the value of attribute path_length
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def path_length @path_length end |
#publish_marker ⇒ Object (readonly)
Returns the value of attribute publish_marker
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def publish_marker @publish_marker end |
#recommended_title ⇒ Object (readonly)
Returns the value of attribute recommended_title
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def recommended_title @recommended_title end |
#selected_anchor_present ⇒ Object (readonly)
Returns the value of attribute selected_anchor_present
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def selected_anchor_present @selected_anchor_present end |
#shallow ⇒ Object (readonly)
Returns the value of attribute shallow
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def shallow @shallow end |
#strong_post_suffix ⇒ Object (readonly)
Returns the value of attribute strong_post_suffix
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def strong_post_suffix @strong_post_suffix end |
#title_word_count ⇒ Object (readonly)
Returns the value of attribute title_word_count
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def title_word_count @title_word_count end |
#utility_path ⇒ Object (readonly)
Returns the value of attribute utility_path
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def utility_path @utility_path end |
#utility_prefix_title ⇒ Object (readonly)
Returns the value of attribute utility_prefix_title
7 8 9 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7 def utility_prefix_title @utility_prefix_title end |
Instance Method Details
#final_score ⇒ Integer
Returns quality minus junk for stable ranking.
53 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 53 def final_score = quality_score - junk_score |
#hard_junk? ⇒ Boolean
Returns true when the entry should be dropped before ranking.
56 57 58 59 60 61 62 63 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 56 def hard_junk? # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity weak = weak_article_candidate? high_confidence_junk_path || (selected_anchor_present && recommended_title && shallow && weak) || (selected_anchor_present && utility_prefix_title && high_confidence_utility_destination && weak) end |
#junk_score ⇒ Integer
Returns junk penalty subtracted from quality.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 40 def junk_score # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity score = 0 score += 25 if non_content_utility_path? score += 15 if utility_prefix_title && title_word_count <= 6 score += 10 if shallow score += 10 if weak_container? score += 10 if recommended_title && !content_path score += 5 if high_confidence_junk_path score += 15 if junk_tokens score end |
#quality_score ⇒ Integer
Returns positive quality contribution for ranking.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 26 def quality_score # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity score = 0 score += 40 if title_word_count >= 3 score += 15 if title_word_count >= 7 score += 20 if path_length > 6 score += 15 if content_path score += 15 if publish_marker score += 10 if descriptive_context score += 10 if article_container score += 10 if content_tokens score end |