| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dezi::Result; |
|
2
|
2
|
|
|
2
|
|
1430
|
use Moose; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
12
|
|
|
3
|
2
|
|
|
2
|
|
13374
|
use MooseX::StrictConstructor; |
|
|
2
|
|
|
|
|
16175
|
|
|
|
2
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
|
|
with 'Dezi::Role'; |
|
5
|
2
|
|
|
2
|
|
11957
|
use Carp; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
139
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use namespace::autoclean; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.014'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'doc' => ( is => 'ro', isa => 'Object', required => 1, ); |
|
11
|
|
|
|
|
|
|
has 'score' => ( is => 'ro', isa => 'Num', required => 1 ); |
|
12
|
|
|
|
|
|
|
has 'property_map' => ( is => 'ro', isa => 'HashRef', required => 1 ); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Dezi::Result - abstract result class |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $results = $searcher->search( 'foo bar' ); |
|
21
|
|
|
|
|
|
|
while (my $result = $results->next) { |
|
22
|
|
|
|
|
|
|
printf("%4d %s\n", $result->score, $result->uri); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Dezi::Result is a abstract class. It defines |
|
28
|
|
|
|
|
|
|
the APIs that all Dezi engines adhere to in |
|
29
|
|
|
|
|
|
|
returning results from a Dezi::InvIndex. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 METHODS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
The following methods are all accessors (getters) only. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 doc |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Returns an object for the backend engine. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 score |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Returns the ranking score for the Result. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 uri |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 mtime |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 title |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 summary |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 swishdocpath |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Alias for uri(). |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 swishlastmodified |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Alias for mtime(). |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 swishtitle |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Alias for title(). |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 swishdescription |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Alias for summary(). |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 swishrank |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Alias for score(). |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
1
|
|
sub uri { shift->doc->swishdocpath } |
|
74
|
0
|
|
|
0
|
1
|
|
sub mtime { shift->doc->swishlastmodified } |
|
75
|
0
|
|
|
0
|
1
|
|
sub summary { shift->doc->swishdescription } |
|
76
|
0
|
|
|
0
|
1
|
|
sub title { shift->doc->swishtitle } |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# version 2 names for the faithful |
|
79
|
0
|
|
|
0
|
1
|
|
sub swishdocpath { shift->uri } |
|
80
|
0
|
|
|
0
|
1
|
|
sub swishlastmodified { shift->mtime } |
|
81
|
0
|
|
|
0
|
1
|
|
sub swishtitle { shift->title } |
|
82
|
0
|
|
|
0
|
1
|
|
sub swishdescription { shift->summary } |
|
83
|
0
|
|
|
0
|
1
|
|
sub swishrank { shift->score } |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 get_property( I<property> ) |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Returns the stored value for I<property> for this Result. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The default behavior is to simply call a method called I<property> |
|
90
|
|
|
|
|
|
|
on the internal doc() object. Subclasses should implement per-engine |
|
91
|
|
|
|
|
|
|
behavior. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub get_property { |
|
96
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
97
|
0
|
0
|
|
|
|
|
my $propname = shift or croak "propname required"; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# if $propname is an alias, use the real property name (how it is stored) |
|
100
|
0
|
0
|
|
|
|
|
if ( exists $self->property_map->{$propname} ) { |
|
101
|
0
|
|
|
|
|
|
$propname = $self->property_map->{$propname}; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
0
|
|
|
|
|
if ( $self->can($propname) ) { |
|
105
|
0
|
|
|
|
|
|
return $self->$propname; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
0
|
|
|
|
|
|
return $self->doc->property($propname); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 get_property_array( I<property> ) |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Returns the stored value for I<property> for the Result. Unlike |
|
113
|
|
|
|
|
|
|
get_property(), the value is always an arrayref, split |
|
114
|
|
|
|
|
|
|
on the libswish3 multi-value character. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Example: |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $val = $result->get_property('foo'); # "green\003blue" |
|
119
|
|
|
|
|
|
|
my $arrval = $result->get_property_array('foo'); # ['green', 'blue'] |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Note that return value will *always* be an arrayref, even if |
|
122
|
|
|
|
|
|
|
the original value does not contain a multi-value character. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub get_property_array { |
|
127
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
128
|
0
|
|
|
|
|
|
my $val = $self->get_property(@_); |
|
129
|
0
|
|
|
|
|
|
return [ split( /\003/, $val ) ]; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 property_map |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Set by the parent Results, a hashref of property aliases to real names. |
|
135
|
|
|
|
|
|
|
Used by get_property(). |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
__END__ |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Peter Karman, E<lt>karpet@dezi.orgE<gt> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 BUGS |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-dezi-app at rt.cpan.org>, or through |
|
152
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dezi-App>. |
|
153
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 SUPPORT |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
perldoc Dezi::Result |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
You can also look for information at: |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=over 4 |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * Website |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L<http://dezi.org/> |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * IRC |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
#dezisearch at freenode |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * Mailing list |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
L<https://groups.google.com/forum/#!forum/dezi-search> |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dezi-App> |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Dezi-App> |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Dezi-App> |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item * Search CPAN |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
L<https://metacpan.org/dist/Dezi-App/> |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=back |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Copyright 2014 by Peter Karman |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
200
|
|
|
|
|
|
|
it under the terms of the GPL v2 or later. |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
L<http://dezi.org/>, L<http://swish-e.org/>, L<http://lucy.apache.org/> |
|
205
|
|
|
|
|
|
|
|