| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
######################### -*- Mode: Perl -*- ######################### |
|
2
|
|
|
|
|
|
|
## |
|
3
|
|
|
|
|
|
|
## File : $RCSfile: Collection.pm,v $ |
|
4
|
|
|
|
|
|
|
## |
|
5
|
|
|
|
|
|
|
## Author : Norbert Goevert |
|
6
|
|
|
|
|
|
|
## Created On : Thu Feb 6 17:43:59 1997 |
|
7
|
|
|
|
|
|
|
## Last Modified : Time-stamp: <2000-11-23 17:40:56 goevert> |
|
8
|
|
|
|
|
|
|
## |
|
9
|
|
|
|
|
|
|
## Description : |
|
10
|
|
|
|
|
|
|
## |
|
11
|
|
|
|
|
|
|
## $Id: Collection.pm,v 1.28 2003/06/13 12:29:30 goevert Exp $ |
|
12
|
|
|
|
|
|
|
## |
|
13
|
|
|
|
|
|
|
###################################################################### |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
520
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
## ################################################################### |
|
20
|
|
|
|
|
|
|
## package RePrec::Collection |
|
21
|
|
|
|
|
|
|
## ################################################################### |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package RePrec::Collection; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
17
|
|
|
|
1
|
|
|
|
|
51
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
539
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
'$Name: release_0_32 $ 0_0' =~ /(\d+)[-_](\d+)/; $VERSION = sprintf '%d.%03d', $1, $2; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
## public ############################################################ |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
my $proto = shift; |
|
38
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto; |
|
39
|
0
|
|
|
|
|
|
my %params = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $self = {}; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
bless $self => $class; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$self->_init(%params); |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $self; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_numdocs { |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
54
|
0
|
|
|
|
|
|
return $self->{numdocs}; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub relevant { |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
61
|
0
|
|
|
|
|
|
my($qid, $docid) = @_; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$self->{qrels}->{$qid}->{$docid}; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get_numrels { |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
70
|
0
|
|
|
|
|
|
my $qid = shift; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
return 0 unless defined $self->{numrels}->{$qid}; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$self->{numrels}->{$qid}; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
## private ########################################################### |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _init { |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
83
|
0
|
|
|
|
|
|
my %parms = @_; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $file = $parms{file}; |
|
86
|
0
|
0
|
|
|
|
|
my $sep = defined $parms{separator} ? $parms{separator} : ' +'; |
|
87
|
0
|
0
|
|
|
|
|
my $ignore = defined $parms{ignore} ? $parms{ignore} : undef; |
|
88
|
0
|
0
|
|
|
|
|
my $qid = defined $parms{qid} ? $parms{qid} : 0; |
|
89
|
0
|
0
|
|
|
|
|
my $docid = defined $parms{docid} ? $parms{docid} : 1; |
|
90
|
0
|
0
|
|
|
|
|
my $judge = defined $parms{judge} ? $parms{judge} : 2; |
|
91
|
0
|
0
|
|
|
|
|
$self->{numdocs} = $parms{numdocs} |
|
92
|
|
|
|
|
|
|
or croak "`Number of documents in collection' parameter missing\n"; |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
my $QRELS = IO::File->new($file) |
|
95
|
|
|
|
|
|
|
or croak "Couldn't read open file `$file': $!\n"; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my(%qrels, %numrels); |
|
98
|
0
|
|
|
|
|
|
local $_; |
|
99
|
0
|
|
|
|
|
|
while (<$QRELS>) { |
|
100
|
0
|
|
|
|
|
|
chomp; |
|
101
|
0
|
0
|
0
|
|
|
|
next if defined $ignore and /$ignore/; |
|
102
|
0
|
|
|
|
|
|
my($_qid, $_docid, $_judge) = (split /$sep/)[$qid, $docid, $judge]; |
|
103
|
0
|
0
|
|
|
|
|
if ($_judge == 1) { |
|
104
|
0
|
|
|
|
|
|
$qrels{$_qid}->{$_docid} = 1; |
|
105
|
0
|
|
|
|
|
|
$numrels{$_qid}++; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$self->{qrels} = \%qrels; |
|
110
|
0
|
|
|
|
|
|
$self->{numrels} = \%numrels; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
|
115
|
|
|
|
|
|
|
__END__ |