Class: Html2rss::AutoSource::LinkHeuristics::ContainerSignals

Inherits:
Data
  • Object
show all
Defined in:
lib/html2rss/auto_source/link_heuristics/container_signals.rb

Overview

Container observations used to compute quality/junk scores.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#article_containerObject (readonly)

Returns the value of attribute article_container

Returns:

  • (Object)

    the current value of article_container



7
8
9
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7

def article_container
  @article_container
end

#content_pathObject (readonly)

Returns the value of attribute content_path

Returns:

  • (Object)

    the current value of content_path



7
8
9
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7

def content_path
  @content_path
end

#content_tokensObject (readonly)

Returns the value of attribute content_tokens

Returns:

  • (Object)

    the current value of content_tokens



7
8
9
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7

def content_tokens
  @content_tokens
end

#descriptive_contextObject (readonly)

Returns the value of attribute descriptive_context

Returns:

  • (Object)

    the current value of 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_pathObject (readonly)

Returns the value of attribute high_confidence_junk_path

Returns:

  • (Object)

    the current value of 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_destinationObject (readonly)

Returns the value of attribute high_confidence_utility_destination

Returns:

  • (Object)

    the current value of 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_tokensObject (readonly)

Returns the value of attribute junk_tokens

Returns:

  • (Object)

    the current value of junk_tokens



7
8
9
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7

def junk_tokens
  @junk_tokens
end

#path_lengthObject (readonly)

Returns the value of attribute path_length

Returns:

  • (Object)

    the current value of path_length



7
8
9
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7

def path_length
  @path_length
end

#publish_markerObject (readonly)

Returns the value of attribute publish_marker

Returns:

  • (Object)

    the current value of publish_marker



7
8
9
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7

def publish_marker
  @publish_marker
end

Returns the value of attribute recommended_title

Returns:

  • (Object)

    the current value of 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_presentObject (readonly)

Returns the value of attribute selected_anchor_present

Returns:

  • (Object)

    the current value of 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

#shallowObject (readonly)

Returns the value of attribute shallow

Returns:

  • (Object)

    the current value of shallow



7
8
9
# File 'lib/html2rss/auto_source/link_heuristics/container_signals.rb', line 7

def shallow
  @shallow
end

#strong_post_suffixObject (readonly)

Returns the value of attribute strong_post_suffix

Returns:

  • (Object)

    the current value of 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_countObject (readonly)

Returns the value of attribute title_word_count

Returns:

  • (Object)

    the current value of 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_pathObject (readonly)

Returns the value of attribute utility_path

Returns:

  • (Object)

    the current value of 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_titleObject (readonly)

Returns the value of attribute utility_prefix_title

Returns:

  • (Object)

    the current value of 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_scoreInteger

Returns quality minus junk for stable ranking.

Returns:

  • (Integer)

    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.

Returns:

  • (Boolean)

    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_scoreInteger

Returns junk penalty subtracted from quality.

Returns:

  • (Integer)

    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_scoreInteger

Returns positive quality contribution for ranking.

Returns:

  • (Integer)

    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