RePrec/Ceiling.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 56 CC 6 SCAR 34.7
CC
6
Cov
0%
precision
42.0
BEGIN
2.0
BEGIN
2.0
CRAP 32.0
1 ######################### -*- Mode: Perl -*- #########################
2 ##
3 ## File : $RCSfile: Ceiling.pm,v $
4 ##
5 ## Author : Sascha Kriewel
6 ## Created On : Tue May 25 14:02:40 1999
7 ## Last Modified : Time-stamp: <2000-11-09 13:34:55 goevert>
8 ##
9 ## Description :
10 ##
11 ## $Id: Ceiling.pm,v 1.19 2003/06/13 12:29:30 goevert Exp $
12 ##
13 ######################################################################
14  
15  
16 use strict;
17  
18  
19 =pod #---------------------------------------------------------------#
20  
21 =head1 NAME
22  
23 RePrec::Ceiling - 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<PRECALLceiling>
32 measure.
33  
34 =head1 METHODS
35  
36 Mainly see RePrec(3). The precision function gives an unique
37 interpretation for each recall point.
38  
39 =cut #---------------------------------------------------------------#
40  
41  
42 package RePrec::Ceiling;
43  
44  
45 use base qw(RePrec);
46  
47  
48 our $VERSION;
49 '$Name: release_0_32 $ 0_0' =~ /(\d+)[-_](\d+)/; $VERSION = sprintf '%d.%03d', $1, $2;
50  
51  
52 ## public ############################################################
53  
54 sub precision {
55  
56 my $self = shift;
57 my @recall = @_;
58  
59 my @result;
60  
61 foreach my $recall (sort @recall) {
62  
63 return undef unless $recall and $recall > 0 and $recall <= 1;
64  
65 # at which number of relevant documents do we stop?
66 my $xn_ceil = $recall * $self->{rels};
67 $xn_ceil = int ($xn_ceil + 1) unless int $xn_ceil == $xn_ceil;
68  
69 # how many ranks do we have to examine?
70 my $rank = $self->{rels_rank}->[$xn_ceil-1];
71  
72 # number of relevant docs within the previous ranks
73 my $k = 0;
74 $k = $self->{rank_rels_nrels}->[$rank - 1]->[0] if $rank;
75 # number of non relevant docs within the previous ranks
76 my $j = 0;
77 $j = $self->{rank_rels_nrels}->[$rank - 1]->[1] if $rank;
78 # number of non relevant docs within the current rank
79 my $i = $self->{rank_rels_nrels}->[$rank]->[1] - $j;
80 # number of relevant docs which must be retrieved from the current rank
81 my $s = $xn_ceil - $k;
82 # number of relevant docs within the current rank
83 my $r = $self->{rank_rels_nrels}->[$rank]->[0] - $k;
84  
85 # do the PRECALL_ceiling formula
86 push @result, [ $recall, $xn_ceil / ($xn_ceil + $j + $s * $i / $r) ];
87 }
88  
89 # interpolation
90 my $maxprec = 0;
91 foreach (reverse @result) {
92 if ($_->[1] < $maxprec) {
93 $_->[1] = $maxprec;
94 } else {
95 $maxprec = $_->[1];
96 }
97 }
98  
99 @result;
100 }
101  
102  
103 =pod #---------------------------------------------------------------#
104  
105 =head1 BUGS
106  
107 Yes. Please let me know!
108  
109 =head1 SEE ALSO
110  
111 RePrec(3),
112 perl(1).
113  
114 =head1 AUTHOR
115  
116 Norbert GE<ouml>vert E<lt>F<goevert@ls6.cs.uni-dortmund.de>E<gt>
117  
118 =cut #---------------------------------------------------------------#
119  
120  
121 1;
122 __END__