| 1 | package Plucene::Search::Scorer; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Plucene::Search::Scorer - base class for scorers | ||||||||||
| 6 | |||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||
| 8 | |||||||||||
| 9 | Abstract base class for scoring. | ||||||||||
| 10 | |||||||||||
| 11 | =cut | ||||||||||
| 12 | |||||||||||
| 13 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 11 | ▶ | use Plucene::Search::Similarity; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | =head2 score | ||||||||||
| 19 | |||||||||||
| 20 | This must be defined in a subclass | ||||||||||
| 21 | |||||||||||
| 22 | =cut | ||||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | sub score { die "score must be defined in a subclass" } | ||||||||
|
Subroutine
score: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 25 | |||||||||||
| 26 | 537 | ▶ | sub _score_it { | ||||||||
|
Subroutine
_score_it: called CC=2 SCAR=6.9
| |||||||||||
| 27 | 537 | my ($self, $freq, $doc, $results) = @_; | |||||||||
| 28 | 537 | ▶ | return unless $freq > 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 488 | my $score = Plucene::Search::Similarity->tf($freq) * $self->weight; | |||||||||
| 30 | 488 | my $norm = substr($self->norms, $doc, 1); | |||||||||
| 31 | 488 | my $norm_freq = Plucene::Search::Similarity->byte_norm($norm); | |||||||||
| 32 | 488 | $score *= $norm_freq; | |||||||||
| 33 | 488 | $results->collect($doc, $score); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 11 | 1; | |||||||||