4 |
use strict; |
use strict; |
5 |
use warnings; |
use warnings; |
6 |
|
|
7 |
our $VERSION = '0.07_3'; |
our $VERSION = '0.08_1'; |
8 |
|
|
9 |
=head1 NAME |
=head1 NAME |
10 |
|
|
188 |
warn "can't decode $line\n"; |
warn "can't decode $line\n"; |
189 |
} |
} |
190 |
next; |
next; |
191 |
|
} elsif ($line =~ m/^%SCORE\t(.+)$/) { |
192 |
|
$self->{score} = $1; |
193 |
|
next; |
194 |
} elsif ($line =~ m/^%/) { |
} elsif ($line =~ m/^%/) { |
195 |
# What is this? comment? |
# What is this? comment? |
196 |
#warn "$line\n"; |
#warn "$line\n"; |
293 |
$self->{kwords} = {@_}; |
$self->{kwords} = {@_}; |
294 |
} |
} |
295 |
|
|
296 |
|
=head2 set_score |
297 |
|
|
298 |
|
Set the substitute score |
299 |
|
|
300 |
|
$doc->set_score(12345); |
301 |
|
|
302 |
|
=cut |
303 |
|
|
304 |
|
sub set_score { |
305 |
|
my $self = shift; |
306 |
|
my $score = shift; |
307 |
|
return unless (defined($score)); |
308 |
|
$self->{score} = $score; |
309 |
|
} |
310 |
|
|
311 |
|
=head2 score |
312 |
|
|
313 |
|
Get the substitute score |
314 |
|
|
315 |
|
=cut |
316 |
|
|
317 |
|
sub score { |
318 |
|
my $self = shift; |
319 |
|
return -1 unless (defined($self->{score})); |
320 |
|
return $self->{score}; |
321 |
|
} |
322 |
|
|
323 |
=head2 id |
=head2 id |
324 |
|
|
420 |
$draft .= "\n"; |
$draft .= "\n"; |
421 |
} |
} |
422 |
|
|
423 |
|
if (defined($self->{score}) && $self->{score} >= 0) { |
424 |
|
$draft .= "%SCORE\t" . $self->{score} . "\n"; |
425 |
|
} |
426 |
|
|
427 |
$draft .= "\n"; |
$draft .= "\n"; |
428 |
|
|
429 |
$draft .= join("\n", @{ $self->{dtexts} }) . "\n" if ($self->{dtexts}); |
$draft .= join("\n", @{ $self->{dtexts} }) . "\n" if ($self->{dtexts}); |
711 |
} |
} |
712 |
|
|
713 |
|
|
714 |
|
=head2 set_distinct |
715 |
|
|
716 |
|
$cond->set_distinct('@author'); |
717 |
|
|
718 |
|
=cut |
719 |
|
|
720 |
|
sub set_distinct { |
721 |
|
my $self = shift; |
722 |
|
$self->{distinct} = shift; |
723 |
|
} |
724 |
|
|
725 |
|
=head2 distinct |
726 |
|
|
727 |
|
Return distinct attribute |
728 |
|
|
729 |
|
print $cond->distinct; |
730 |
|
|
731 |
|
=cut |
732 |
|
|
733 |
|
sub distinct { |
734 |
|
my $self = shift; |
735 |
|
return $self->{distinct}; |
736 |
|
} |
737 |
|
|
738 |
|
=head2 set_mask |
739 |
|
|
740 |
|
Filter out some links when searching. |
741 |
|
|
742 |
|
Argument array of link numbers, starting with 0 (current node). |
743 |
|
|
744 |
|
$cond->set_mask(qw/0 1 4/); |
745 |
|
|
746 |
|
=cut |
747 |
|
|
748 |
|
sub set_mask { |
749 |
|
my $self = shift; |
750 |
|
return unless (@_); |
751 |
|
$self->{mask} = \@_; |
752 |
|
} |
753 |
|
|
754 |
|
|
755 |
package Search::Estraier::ResultDocument; |
package Search::Estraier::ResultDocument; |
756 |
|
|
757 |
use Carp qw/croak/; |
use Carp qw/croak/; |
1638 |
push @args, 'awidth=' . $self->{awidth}; |
push @args, 'awidth=' . $self->{awidth}; |
1639 |
push @args, 'skip=' . $cond->{skip} if ($cond->{skip}); |
push @args, 'skip=' . $cond->{skip} if ($cond->{skip}); |
1640 |
|
|
1641 |
|
if (my $distinct = $cond->distinct) { |
1642 |
|
push @args, 'distinct=' . uri_escape($distinct); |
1643 |
|
} |
1644 |
|
|
1645 |
|
if ($cond->{mask}) { |
1646 |
|
my $mask = 0; |
1647 |
|
map { $mask += ( 2 ** $_ ) } @{ $cond->{mask} }; |
1648 |
|
|
1649 |
|
push @args, 'mask=' . $mask if ($mask); |
1650 |
|
} |
1651 |
|
|
1652 |
return join('&', @args); |
return join('&', @args); |
1653 |
} |
} |
1654 |
|
|