Plucene/Search/PhraseScorer/Sloppy.pm

filter: Statementstmt 100% 43 / 43 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 58 / 58 CC 6 SCAR 13.9
CC
6
Cov
100%
_phrase_freq
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« Plucene/Index/Writer.pm ↑ Summary Plucene/Index/TermInfosWriter.pm »
1 package Plucene::Search::PhraseScorer::Sloppy;
2  
3 =head1 NAME
4  
5 Plucene::Search::PhraseScorer::Sloppy - sloppy phrase scorer
6  
7 =head1 SYNOPSIS
8  
9 # isa Plucene::Search::PhraseScorer
10  
11 =head1 DESCRIPTION
12  
13 This is a sloppy phrase scorer
14  
15 =head1 METHODS
16  
17 =cut
18  
19 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 4 ▶use List::Util qw(max);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 4 ▶use base 'Plucene::Search::PhraseScorer';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 4 __PACKAGE__->mk_accessors(q{slop});
27  
28 10 ▶sub _phrase_freq {
Subroutine _phrase_freq: called CC=6 SCAR=17.9
29 10 my $self = shift;
30 10 my $end = 0;
31 10 $#{ $self->{pq} } = -1;
32 10 my $pp = $self->first;
33 10 ▶ while ($pp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pp) 20 10 30
34 20 $pp->first_position;
35 20 $end = max($end, $pp->position);
36 20 push @{ $self->{pq} }, $pp;
37 20 $pp = $pp->next_in_list;
38 }
39  
40 10 my $freq = 0;
41 10 my $done = 0;
42 10 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$done or do { do { my $pp = shift @{$$self{"pq"};}; my $start = $pp->position; my $next = $self->{"pq"}[0]->position; for (my $pos = $start; $pos <= $next; $pos = $pp->position) { $start = $pos; unless ($pp->next_position) { $done = 1; last; } ; } ; my $length = $end - $start; $freq += 1 / ($length + 1) if $length <= $self->slop; $end = &max($end, $pp->position); push @{$$self{"pq"};}, $pp } } 10 21 31
43 31 my $pp = shift @{ $self->{pq} };
44 31 my $start = $pp->position;
45 31 my $next = $self->{pq}->[0]->position;
46 31 ▶ for (my $pos = $start ; $pos <= $next ; $pos = $pp->position) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos <= $next) 59 21 80
47 59 $start = $pos;
48 59 ▶ if (!$pp->next_position) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pp->next_position) 10 49 59
49 10 $done = 1;
50 10 last;
51 }
52 }
53  
54 31 my $length = $end - $start;
55 31 ▶ $freq += 1 / ($length + 1) if $length <= $self->slop;
Branch: 1 branch
BranchTrueFalseTotal
if $length <= $self->slop 7 24 31
56 31 $end = max($end, $pp->position);
57 31 push @{ $self->{pq} }, $pp;
58 } while (!$done);
59 10 return $freq;
60 }
61  
62 4 1;
« Plucene/Index/Writer.pm ↑ Summary Plucene/Index/TermInfosWriter.pm »