Class: Html2rss::HtmlExtractor::SemanticAnchorCandidates::Score

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/html_extractor/semantic_anchor_candidates.rb

Overview

Scores an eligible semantic anchor candidate.

Constant Summary collapse

RULES =

Score weights keyed by candidate signal predicate.

{
  heading_anchor?: 100,
  heading_text_match?: 20,
  meaningful_text?: 10,
  content_like_destination?: 10
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(candidate) ⇒ Score

Returns a new instance of Score.

Parameters:

  • candidate (Candidate)

    eligible semantic anchor candidate



213
214
215
# File 'lib/html2rss/html_extractor/semantic_anchor_candidates.rb', line 213

def initialize(candidate)
  @candidate = candidate
end

Instance Method Details

#valueInteger

Returns ranking score.

Returns:

  • (Integer)

    ranking score



218
219
220
# File 'lib/html2rss/html_extractor/semantic_anchor_candidates.rb', line 218

def value
  RULES.sum { |predicate, weight| @candidate.public_send(predicate) ? weight : 0 }
end