Class: Ferret::Search::ExactPhraseScorer
- Inherits:
-
PhraseScorer
- Object
- Scorer
- PhraseScorer
- Ferret::Search::ExactPhraseScorer
- Defined in:
- lib/ferret/search/exact_phrase_scorer.rb
Constant Summary
Constants inherited from Scorer
Instance Attribute Summary
Attributes inherited from Scorer
Instance Method Summary collapse
-
#initialize(weight, tps, positions, similarity, norms) ⇒ ExactPhraseScorer
constructor
A new instance of ExactPhraseScorer.
- #phrase_freq ⇒ Object
Methods inherited from PhraseScorer
#do_next, #doc, #each, #explain, #first_to_last, #init, #next?, #pq_to_list, #score, #skip_to, #sort, #to_s
Methods inherited from Scorer
#doc, #each_hit, #each_hit_up_to, #explain, #next?, #score, #skip_to
Constructor Details
#initialize(weight, tps, positions, similarity, norms) ⇒ ExactPhraseScorer
Returns a new instance of ExactPhraseScorer.
4 5 6 |
# File 'lib/ferret/search/exact_phrase_scorer.rb', line 4 def initialize(weight, tps, positions, similarity, norms) super(weight, tps, positions, similarity, norms) end |
Instance Method Details
#phrase_freq ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ferret/search/exact_phrase_scorer.rb', line 8 def phrase_freq() # sort list with pq each do |pp| pp.first_position() @pq.push(pp) # build pq from list end pq_to_list() # rebuild list from pq freq = 0 begin # find position w/ all terms while (@first.position < @last.position) # scan forward in first begin if not @first.next_position() return freq end end while (@first.position < @last.position) first_to_last() end freq += 1 # all equal: a match end while @last.next_position() return freq end |