RePrec/PRR.pm

filter: Statementstmt 35.7% 10 / 28 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 26.5% 13 / 49 CC 8 SCAR 40.6
CC
8
Cov
24%
precision
72.0
BEGIN
1.0
BEGIN
1.0
CRAP 57.8
« RePrec.pm ↑ Summary RePrec/Ceiling.pm »
1 ######################### -*- Mode: Perl -*- #########################
2 ##
3 ## File : $RCSfile: PRR.pm,v $
4 ##
5 ## Author : Norbert Goevert
6 ## Created On : Wed Feb 5 11:19:51 1997
7 ## Last Modified : Time-stamp: <2000-11-09 18:20:07 goevert>
8 ##
9 ## Description :
10 ##
11 ## $Id: PRR.pm,v 1.28 2003/06/13 12:29:30 goevert Exp $
12 ##
13 ######################################################################
14  
15  
16 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 =pod #---------------------------------------------------------------#
20  
21 =head1 NAME
22  
23 RePrec::PRR - compute precision values
24  
25 =head1 SYNOPSIS
26  
27 (see RePrec(3))
28  
29 =head1 DESCRIPTION
30  
31 Computation of precision values according to the I<Probability of
32 Relevance> measure (user standpoint: stop at a given number of
33 relevant documents retrieved).
34  
35 =head1 METHODS
36  
37 Mainly see RePrec(3). The precision function gives an unique
38 interpretation for each recall point. Precision can be computed for
39 any recall point.
40  
41 =cut #---------------------------------------------------------------#
42  
43  
44 package RePrec::PRR;
45  
46  
47 1 ▶use base qw(RePrec);
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49  
50 1 our $VERSION;
51 1 '$Name: release_0_32 $ 0_0' =~ /(\d+)[-_](\d+)/; $VERSION = sprintf '%d.%03d', $1, $2;
52  
53  
54 ## public ############################################################
55  
56 0 ▶sub precision {
Subroutine precision: not called CC=8 SCAR=42.8
Pod documented
57  
58 0 my $self = shift;
59 0 my @recall = @_;
60  
61 0 my @result;
62  
63 0 foreach my $recall (@recall) {
64  
65 0 ▶ return undef unless $recall and $recall > 0 and $recall <= 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $recall and $recall > 0 and $recall <= 1 0 0 0
Condition0%0/6
$recall and $recall > 0 and $recall <= 1
!ll&&!rl&&r
000
$recall and $recall > 0
!ll&&!rl&&r
000
MC/DC0%0/3
$recall and $recall > 0 and $recall <= 1
$recall $recall > 0 $recall <= 1
Truth table0%0/4
A and B and C
A= $recallB= $recall > 0C= $recall <= 1
ABCresult
0XX0
10X0
1100
1111
66  
67 # at which number of relevant documents do we stop?
68 0 my $NR = $recall * $self->{rels};
69  
70 # how many ranks do we have to examine?
71 0 my $NRint = int $NR;
72 0 ▶ $NRint++ if $NR > $NRint;
Branch: 1 branch
BranchTrueFalseTotal
if $NR > $NRint 0 0 0
73 0 my $rank = $self->{rels_rank}->[$NRint - 1];
74 #print STDERR "$rank $recall $NR $NRint\n";
75  
76 # number of relevant docs within the previous ranks
77 0 my $k = 0;
78 0 ▶ $k = $self->{rank_rels_nrels}->[$rank - 1]->[0] if $rank;
Branch: 1 branch
BranchTrueFalseTotal
if $rank 0 0 0
79 # number of non relevant docs within the previous ranks
80 0 my $j = 0;
81 0 ▶ $j = $self->{rank_rels_nrels}->[$rank - 1]->[1] if $rank;
Branch: 1 branch
BranchTrueFalseTotal
if $rank 0 0 0
82 # number of non relevant docs within the current rank
83 0 my $i = $self->{rank_rels_nrels}->[$rank]->[1] - $j;
84 # number of relevant docs which must be retrieved from the current rank
85 0 my $s = $NRint - $k;
86 # number of relevant docs within the current rank
87 0 my $r = $self->{rank_rels_nrels}->[$rank]->[0] - $k;
88  
89 # do the PRR formula
90 0 push @result, [ $recall, $NR / ($NR + $j + $s * $i / ($r + 1.0)) ];
91 }
92  
93 0 @result;
94 }
95  
96  
97 ## private ###########################################################
98  
99  
100 =pod #---------------------------------------------------------------#
101  
102 =head1 BUGS
103  
104 Yes. Please let me know!
105  
106 =head1 SEE ALSO
107  
108 RePrec(3),
109 perl(1).
110  
111 =head1 AUTHOR
112  
113 Norbert GE<ouml>vert E<lt>F<goevert@ls6.cs.uni-dortmund.de>E<gt>
114  
115 =cut #---------------------------------------------------------------#
116  
117  
118 1 1;
119 __END__
« RePrec.pm ↑ Summary RePrec/Ceiling.pm »