/usr/share/perl5/Plucene/Search/TermScorer.pm is in libplucene-perl 1.25-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | package Plucene::Search::TermScorer;
=head1 NAME
Plucene::Search::TermScorer - score terms
=head1 SYNOPSIS
# isa Plucene::Search::Scorer
$term_scorer->score($hc, $end);
=head1 DESCRIPTION
This is a Plucene::Search::Scorer subclass for scoring terms.
=head1 METHODS
=cut
use strict;
use warnings;
use constant SCORE_CACHE_SIZE => 32;
use Plucene::Search::Similarity;
use base qw(Plucene::Search::Scorer Class::Accessor::Fast);
=head2 term_docs / norms / weight / doc / docs / freqs / pointer /
pointer_max / score_cache
Get / set these attributes
=cut
__PACKAGE__->mk_accessors(
qw(term_docs norms weight doc docs freqs
pointer pointer_max score_cache)
);
sub new {
my $self = shift->SUPER::new(@_);
$self->weight(1) unless $self->weight();
$self->_compute_score_cache;
$self->_refill_buffers;
return $self;
}
sub _compute_score_cache {
my $self = shift;
for (0 .. SCORE_CACHE_SIZE - 1) {
$self->{score_cache}[$_] =
Plucene::Search::Similarity->tf($_) * $self->weight;
}
}
sub _refill_buffers {
my $self = shift;
$self->pointer(0);
my ($docs, $freqs) = $self->{term_docs}->read;
$self->docs($docs);
$self->freqs($freqs);
$self->pointer_max(scalar @$docs);
if ($self->{pointer_max} > 0) {
$self->doc($docs->[0]);
} else {
$self->doc(~0);
} # Sentinel
}
=head2 score
$term_scorer->score($hc, $end);
=cut
sub score {
my ($self, $hc, $end) = @_;
my $d = $self->doc;
while ($d < $end) {
my $f = $self->{freqs}->[ $self->{pointer} ];
$self->_score_it($f, $d, $hc);
if (++$self->{pointer} == $self->{pointer_max}) {
$self->_refill_buffers;
return if $self->doc == ~0;
}
$d = $self->{docs}[ $self->{pointer} ];
}
$self->doc($d);
}
1;
|