4 |
use strict; |
use strict; |
5 |
use warnings; |
use warnings; |
6 |
|
|
7 |
our $VERSION = '0.07_2'; |
our $VERSION = '0.07_3'; |
8 |
|
|
9 |
=head1 NAME |
=head1 NAME |
10 |
|
|
182 |
|
|
183 |
if ($line =~ m/^%VECTOR\t(.+)$/) { |
if ($line =~ m/^%VECTOR\t(.+)$/) { |
184 |
my @fields = split(/\t/, $1); |
my @fields = split(/\t/, $1); |
185 |
for my $i ( 0 .. ($#fields - 1) ) { |
if ($#fields % 2 == 1) { |
186 |
$self->{kwords}->{ $fields[ $i ] } = $fields[ $i + 1 ]; |
$self->{kwords} = { @fields }; |
187 |
$i++; |
} else { |
188 |
|
warn "can't decode $line\n"; |
189 |
} |
} |
190 |
next; |
next; |
191 |
} elsif ($line =~ m/^%/) { |
} elsif ($line =~ m/^%/) { |
269 |
push @{ $self->{htexts} }, $self->_s($text); |
push @{ $self->{htexts} }, $self->_s($text); |
270 |
} |
} |
271 |
|
|
272 |
|
=head2 add_vectors |
273 |
|
|
274 |
|
Add a vectors |
275 |
|
|
276 |
|
$doc->add_vector( |
277 |
|
'vector_name' => 42, |
278 |
|
'another' => 12345, |
279 |
|
); |
280 |
|
|
281 |
|
=cut |
282 |
|
|
283 |
|
sub add_vectors { |
284 |
|
my $self = shift; |
285 |
|
return unless (@_); |
286 |
|
|
287 |
|
# this is ugly, but works |
288 |
|
die "add_vector needs HASH as argument" unless ($#_ % 2 == 1); |
289 |
|
|
290 |
|
$self->{kwords} = {@_}; |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
=head2 id |
=head2 id |
295 |
|
|
384 |
} |
} |
385 |
|
|
386 |
if ($self->{kwords}) { |
if ($self->{kwords}) { |
387 |
$draft .= '%%VECTOR'; |
$draft .= '%VECTOR'; |
388 |
while (my ($key, $value) = each %{ $self->{kwords} }) { |
while (my ($key, $value) = each %{ $self->{kwords} }) { |
389 |
$draft .= "\t$key\t$value"; |
$draft .= "\t$key\t$value"; |
390 |
} |
} |
677 |
return $self->{skip}; |
return $self->{skip}; |
678 |
} |
} |
679 |
|
|
680 |
|
=head2 set_mask |
681 |
|
|
682 |
|
Select just some links when searching and not all. |
683 |
|
|
684 |
|
Argument array of link numbers, starting with 0. |
685 |
|
|
686 |
|
$cond->set_mask(qw/0 1 4/); |
687 |
|
|
688 |
|
=cut |
689 |
|
|
690 |
|
sub set_mask { |
691 |
|
my $self = shift; |
692 |
|
return unless (@_); |
693 |
|
$self->{mask} = \@_; |
694 |
|
} |
695 |
|
|
696 |
|
|
697 |
package Search::Estraier::ResultDocument; |
package Search::Estraier::ResultDocument; |
698 |
|
|
1369 |
$path = '/etch_doc' if ($a->{etch}); |
$path = '/etch_doc' if ($a->{etch}); |
1370 |
|
|
1371 |
if ($a->{id}) { |
if ($a->{id}) { |
1372 |
croak "id must be numberm not '$a->{id}'" unless ($a->{id} =~ m/^\d+$/); |
croak "id must be number not '$a->{id}'" unless ($a->{id} =~ m/^\d+$/); |
1373 |
$arg = 'id=' . $a->{id}; |
$arg = 'id=' . $a->{id}; |
1374 |
} elsif ($a->{uri}) { |
} elsif ($a->{uri}) { |
1375 |
$arg = 'uri=' . uri_escape($a->{uri}); |
$arg = 'uri=' . uri_escape($a->{uri}); |
1580 |
push @args, 'awidth=' . $self->{awidth}; |
push @args, 'awidth=' . $self->{awidth}; |
1581 |
push @args, 'skip=' . $cond->{skip} if ($cond->{skip}); |
push @args, 'skip=' . $cond->{skip} if ($cond->{skip}); |
1582 |
|
|
1583 |
|
if ($cond->{mask}) { |
1584 |
|
my $mask = 0; |
1585 |
|
map { $mask += ( 2 ** $_ ) } @{ $cond->{mask} }; |
1586 |
|
|
1587 |
|
push @args, 'mask=' . $mask if ($mask); |
1588 |
|
} |
1589 |
|
|
1590 |
return join('&', @args); |
return join('&', @args); |
1591 |
} |
} |
1592 |
|
|