line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
11
|
|
69
|
use strict; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
352
|
|
14
|
11
|
|
|
11
|
|
57
|
use warnings; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
266
|
|
15
|
|
|
|
|
|
|
|
16
|
11
|
|
|
11
|
|
57
|
use Plucene::Search::Similarity; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
1945
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 score |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This must be defined in a subclass |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
1
|
0
|
sub score { die "score must be defined in a subclass" } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _score_it { |
27
|
408
|
|
|
408
|
|
1412
|
my ($self, $freq, $doc, $results) = @_; |
28
|
408
|
100
|
|
|
|
1622
|
return unless $freq > 0; |
29
|
372
|
|
|
|
|
1574
|
my $score = Plucene::Search::Similarity->tf($freq) * $self->weight; |
30
|
372
|
|
|
|
|
2792
|
my $norm = substr($self->norms, $doc, 1); |
31
|
372
|
|
|
|
|
3212
|
my $norm_freq = Plucene::Search::Similarity->byte_norm($norm); |
32
|
372
|
|
|
|
|
655
|
$score *= $norm_freq; |
33
|
372
|
|
|
|
|
1402
|
$results->collect($doc, $score); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |