line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
767
|
use warnings; |
|
5
|
|
|
|
|
38
|
|
|
5
|
|
|
|
|
143
|
|
2
|
5
|
|
|
5
|
|
25
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
140
|
|
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
1158
|
use Data::Dumper; |
|
5
|
|
|
|
|
11004
|
|
|
5
|
|
|
|
|
2018
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Search::Lemur::ResultItem; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Lemur::ResultItem |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 1.0 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
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 die. |
39
|
|
|
|
|
|
|
sub _new { |
40
|
12
|
|
|
12
|
|
53
|
my $class = shift; |
41
|
12
|
|
|
|
|
17
|
my $self = {}; |
42
|
12
|
50
|
|
|
|
53
|
if (scalar(@_) == 3) { |
43
|
12
|
|
|
|
|
21
|
my ($docid, $doclen, $tf) = @_; |
44
|
12
|
|
|
|
|
41
|
$self = { docid => $docid, |
45
|
|
|
|
|
|
|
doclen => $doclen, |
46
|
|
|
|
|
|
|
tf => $tf }; |
47
|
0
|
|
|
|
|
0
|
} else { die "Not enough arguments to create a resultItem object."; } |
48
|
12
|
|
|
|
|
30
|
bless $self, $class; |
49
|
12
|
|
|
|
|
33
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item docid |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Get the document ID value for this result. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub docid { |
59
|
14
|
|
|
14
|
1
|
20
|
my $self = shift; |
60
|
14
|
50
|
|
|
|
30
|
if (@_) { $self->{url} = shift; } |
|
0
|
|
|
|
|
0
|
|
61
|
14
|
|
|
|
|
91
|
return $self->{docid}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item doclen |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Get the document length for this result. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub doclen { |
71
|
16
|
|
|
16
|
1
|
28
|
my $self = shift; |
72
|
16
|
50
|
|
|
|
33
|
if (@_) { $self->{url} = shift; } |
|
0
|
|
|
|
|
0
|
|
73
|
16
|
|
|
|
|
76
|
return $self->{doclen}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item tf |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Get the term frequency value for this result. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub tf { |
84
|
18
|
|
|
18
|
1
|
24
|
my $self = shift; |
85
|
18
|
50
|
|
|
|
37
|
if (@_) { $self->{url} = shift; } |
|
0
|
|
|
|
|
0
|
|
86
|
18
|
|
|
|
|
88
|
return $self->{tf}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item equals |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Test equality between this resultItem and the given one (used mostly for |
92
|
|
|
|
|
|
|
testing). |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub equals { |
97
|
9
|
|
|
9
|
1
|
20
|
my $self = shift; |
98
|
9
|
|
|
|
|
14
|
my $other = shift; |
99
|
9
|
100
|
|
|
|
64
|
return 0 unless ($other->isa('Search::Lemur::ResultItem')); |
100
|
8
|
|
100
|
|
|
20
|
return ($self->tf() == $other->tf()) && |
101
|
|
|
|
|
|
|
($self->doclen() == $other->doclen()) && |
102
|
|
|
|
|
|
|
($self->docid() == $other->docid()); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Patrick Kaeding, C<< >> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 BUGS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
114
|
|
|
|
|
|
|
C, or through the web interface at |
115
|
|
|
|
|
|
|
L. |
116
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
117
|
|
|
|
|
|
|
your bug as I make changes. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SUPPORT |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
perldoc Search::Lemur |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
You can also look for information at: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=over 4 |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * CPAN Ratings |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * Search CPAN |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Copyright 2007 Patrick Kaeding, all rights reserved. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
154
|
|
|
|
|
|
|
under the same terms as Perl itself. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
1; |