line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
1
|
|
517
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
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
|
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
|
|
|
1
|
|
4
|
use base qw(RePrec); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
276
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
our $VERSION; |
51
|
|
|
|
|
|
|
'$Name: release_0_32 $ 0_0' =~ /(\d+)[-_](\d+)/; $VERSION = sprintf '%d.%03d', $1, $2; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
## public ############################################################ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub precision { |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
my @recall = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my @result; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
foreach my $recall (@recall) { |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
0
|
|
|
|
return undef unless $recall and $recall > 0 and $recall <= 1; |
|
|
|
0
|
|
|
|
|
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
|
0
|
|
|
|
|
$NRint++ if $NR > $NRint; |
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
|
0
|
|
|
|
|
$k = $self->{rank_rels_nrels}->[$rank - 1]->[0] if $rank; |
79
|
|
|
|
|
|
|
# number of non relevant docs within the previous ranks |
80
|
0
|
|
|
|
|
|
my $j = 0; |
81
|
0
|
0
|
|
|
|
|
$j = $self->{rank_rels_nrels}->[$rank - 1]->[1] if $rank; |
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 GEvert EFE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut #---------------------------------------------------------------# |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
__END__ |