Class: Html2rss::Scoring::Observation

Inherits:
Data
  • Object
show all
Defined in:
lib/html2rss/scoring/observation.rb

Overview

Typed container signals produced by ContainerAssessor for Engine rules.

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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.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/scoring/observation.rb', line 7

def utility_prefix_title
  @utility_prefix_title
end

Instance Method Details

#hard_junk?(mode: :strict) ⇒ Boolean

Returns true when the observation should be dropped before ranking.

Parameters:

  • mode (Symbol) (defaults to: :strict)

    :strict for rank/rank_top; :lenient for select_eligible

Returns:

  • (Boolean)

    true when the observation should be dropped before ranking



34
35
36
37
38
39
40
41
42
43
# File 'lib/html2rss/scoring/observation.rb', line 34

def hard_junk?(mode: :strict)
  case mode
  when :strict
    high_confidence_junk_path || chrome_title_junk?
  when :lenient
    (high_confidence_junk_path && weak_signals?) || chrome_title_junk?
  else
    raise ArgumentError, "unknown hard_junk mode: #{mode.inspect}"
  end
end

#weak_signals?Boolean

Returns true when fewer than two positive content signals are present.

Returns:

  • (Boolean)

    true when fewer than two positive content signals are present



27
28
29
# File 'lib/html2rss/scoring/observation.rb', line 27

def weak_signals?
  [article_container, publish_marker, descriptive_context, content_path].count(&:itself) < 2
end