| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
274
|
|
|
2
|
5
|
|
|
5
|
|
26
|
use strict; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
6725
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Search::Lemur::Result; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Lemur::Result |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 1.0 |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Stores the results from a lemur query for a single term. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 Main Methods |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=over 2 |
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# create a new result object. This should only be called by a |
|
32
|
|
|
|
|
|
|
# Lemur object, in its query method. One of these will be created |
|
33
|
|
|
|
|
|
|
# for every result returned by the query. |
|
34
|
|
|
|
|
|
|
# |
|
35
|
|
|
|
|
|
|
# The arguments are query term, the document ID, document length, |
|
36
|
|
|
|
|
|
|
# and term frequency. |
|
37
|
|
|
|
|
|
|
# |
|
38
|
|
|
|
|
|
|
# If these arguments are not given, this will return undef |
|
39
|
|
|
|
|
|
|
sub _new { |
|
40
|
8
|
|
|
8
|
|
47
|
my $class = shift; |
|
41
|
8
|
|
|
|
|
11
|
my $self = {}; |
|
42
|
8
|
50
|
|
|
|
38
|
if (scalar(@_) >= 3) { |
|
43
|
8
|
|
|
|
|
16
|
my ($term, $ctf, $df) = @_; |
|
44
|
8
|
|
|
|
|
34
|
$self = { term => $term, |
|
45
|
|
|
|
|
|
|
ctf => $ctf, |
|
46
|
|
|
|
|
|
|
df => $df, |
|
47
|
|
|
|
|
|
|
lines => [] }; |
|
48
|
0
|
|
|
|
|
0
|
} else { return undef; } |
|
49
|
8
|
|
|
|
|
20
|
bless $self, $class; |
|
50
|
8
|
|
|
|
|
22
|
return $self; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item ctf |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Get the corpus term frequency for this result. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub ctf { |
|
60
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
61
|
0
|
|
|
|
|
0
|
return $self->{ctf}; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item term |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Get the query term for this result. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns the number of times this term occured in the corpus. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub term { |
|
74
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
75
|
0
|
|
|
|
|
0
|
return $self->{term}; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item df |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Get the document frequency for this result. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Returns the number of documents this term occurred in. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub df { |
|
87
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
88
|
0
|
|
|
|
|
0
|
return $self->{df}; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item docs |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Get the array of documents returned by this query. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns an array of resultItem objects. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub docs { |
|
101
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
102
|
0
|
|
|
|
|
0
|
return $self->{lines}; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# _add(resultItem) |
|
106
|
|
|
|
|
|
|
# |
|
107
|
|
|
|
|
|
|
# add a resultItem to the list |
|
108
|
|
|
|
|
|
|
# |
|
109
|
|
|
|
|
|
|
# This should only be called by Lemur objects' _parse method when |
|
110
|
|
|
|
|
|
|
# populating the result |
|
111
|
|
|
|
|
|
|
sub _add { |
|
112
|
8
|
|
|
8
|
|
20
|
my $self = shift; |
|
113
|
8
|
|
|
|
|
8
|
my $line = shift; |
|
114
|
8
|
|
|
|
|
18
|
push @{$self->{lines}}, $line; |
|
|
8
|
|
|
|
|
31
|
|
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item equals |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Test equality between this result and the given one (used mostly for |
|
120
|
|
|
|
|
|
|
testing). |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub equals { |
|
126
|
5
|
|
|
5
|
1
|
16
|
my $self = shift; |
|
127
|
5
|
|
|
|
|
6
|
my $other = shift; |
|
128
|
5
|
50
|
|
|
|
30
|
return 0 unless ($other->isa('Search::Lemur::Result')); |
|
129
|
5
|
|
|
|
|
7
|
my $numlines = scalar(@{$self->{lines}}); |
|
|
5
|
|
|
|
|
13
|
|
|
130
|
5
|
100
|
|
|
|
7
|
return 0 unless ($numlines == @{$other->{lines}}); |
|
|
5
|
|
|
|
|
17
|
|
|
131
|
|
|
|
|
|
|
# check that the resultItems are all the same (order matters) |
|
132
|
4
|
|
|
|
|
16
|
for (my $i = 0; $i < $numlines; $i++){ |
|
133
|
4
|
|
|
|
|
9
|
return 0 unless (${$self->{lines}}[$i]->equals( |
|
|
4
|
|
|
|
|
17
|
|
|
134
|
4
|
50
|
|
|
|
5
|
${$self->{lines}}[$i])); |
|
135
|
|
|
|
|
|
|
} |
|
136
|
4
|
|
33
|
|
|
68
|
return ($self->{term} eq $other->{term}) && |
|
137
|
|
|
|
|
|
|
($self->{ctf} == $other->{ctf}) && |
|
138
|
|
|
|
|
|
|
($self->{df} == $other->{df}); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=back |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Patrick Kaeding, C<< >> |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 BUGS |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
151
|
|
|
|
|
|
|
C, or through the web interface at |
|
152
|
|
|
|
|
|
|
L. |
|
153
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
154
|
|
|
|
|
|
|
your bug as I make changes. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 SUPPORT |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
perldoc Search::Lemur |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
You can also look for information at: |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=over 4 |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
L |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
L |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item * Search CPAN |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
L |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=back |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Copyright 2007 Patrick Kaeding, all rights reserved. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
191
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
1; |