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



196
197
198
# File 'lib/html2rss/html_extractor/semantic_anchor_candidates.rb', line 196

def initialize(candidate)
  @candidate = candidate
end

Instance Method Details

#valueInteger

Returns ranking score.

Returns:

  • (Integer)

    ranking score



201
202
203
# File 'lib/html2rss/html_extractor/semantic_anchor_candidates.rb', line 201

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