--- trunk/Estraier.pm 2006/08/06 18:15:56 174 +++ trunk/Estraier.pm 2006/11/04 13:10:29 184 @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.07_3'; +our $VERSION = '0.08_1'; =head1 NAME @@ -188,6 +188,9 @@ warn "can't decode $line\n"; } next; + } elsif ($line =~ m/^%SCORE\t(.+)$/) { + $self->{score} = $1; + next; } elsif ($line =~ m/^%/) { # What is this? comment? #warn "$line\n"; @@ -290,6 +293,32 @@ $self->{kwords} = {@_}; } +=head2 set_score + +Set the substitute score + + $doc->set_score(12345); + +=cut + +sub set_score { + my $self = shift; + my $score = shift; + return unless (defined($score)); + $self->{score} = $score; +} + +=head2 score + +Get the substitute score + +=cut + +sub score { + my $self = shift; + return -1 unless (defined($self->{score})); + return $self->{score}; +} =head2 id @@ -391,11 +420,17 @@ $draft .= "\n"; } + if (defined($self->{score}) && $self->{score} >= 0) { + $draft .= "%SCORE\t" . $self->{score} . "\n"; + } + $draft .= "\n"; $draft .= join("\n", @{ $self->{dtexts} }) . "\n" if ($self->{dtexts}); $draft .= "\t" . join("\n\t", @{ $self->{htexts} }) . "\n" if ($self->{htexts}); + printf("[%s]\n", $draft); + return $draft; } @@ -677,6 +712,31 @@ return $self->{skip}; } + +=head2 set_distinct + + $cond->set_distinct('@author'); + +=cut + +sub set_distinct { + my $self = shift; + $self->{distinct} = shift; +} + +=head2 distinct + +Return distinct attribute + + print $cond->distinct; + +=cut + +sub distinct { + my $self = shift; + return $self->{distinct}; +} + =head2 set_mask Filter out some links when searching. @@ -1580,6 +1640,10 @@ push @args, 'awidth=' . $self->{awidth}; push @args, 'skip=' . $cond->{skip} if ($cond->{skip}); + if (my $distinct = $cond->distinct) { + push @args, 'distinct=' . uri_escape($distinct); + } + if ($cond->{mask}) { my $mask = 0; map { $mask += ( 2 ** $_ ) } @{ $cond->{mask} };