prevent warnings caused by having indexas reset the phrase weights
authorTony Cook <tony@develop-help.com>
Tue, 2 Oct 2007 01:51:06 +0000 (01:51 +0000)
committertony <tony@45cb6cf1-00bc-42d2-bb5a-07f51df49f94>
Tue, 2 Oct 2007 01:51:06 +0000 (01:51 +0000)
site/cgi-bin/modules/BSE/Index/BSE.pm

index c96b603..5bd6ffb 100644 (file)
@@ -34,7 +34,7 @@ sub start_index {
   my %stopwords;
   @stopwords{@stopwords} = (1) x @stopwords;
   close STOP;
-
+  $self->{weights} = {};
 
   return 1;
 }
@@ -42,8 +42,7 @@ sub start_index {
 sub process_article {
   my ($self, $article, $section, $indexas, $fields) = @_;
 
-  my %weights;
-
+  $self->{weights}{$indexas} ||= {};
   for my $field (sort { $self->{scores}{$b} <=> $self->{scores}{$a} }
                 keys %$fields) {
     my $text = $fields->{$field};
@@ -57,7 +56,7 @@ sub process_article {
       
       for my $word (@words) {
        if ($self->{stopwords}{lc $word}) {
-         $self->process($indexas, $section->{id}, $score, \%weights, \%seen,
+         $self->process($indexas, $section->{id}, $score, $self->{weights}{$indexas}, \%seen,
                         @buffer) if @buffer;
          @buffer = ();
        }
@@ -65,7 +64,7 @@ sub process_article {
          push(@buffer, $word);
        }
       }
-      $self->process($indexas, $section->{id}, $score, \%weights, \%seen,
+      $self->process($indexas, $section->{id}, $score, $self->{weights}{$indexas}, \%seen,
                     @buffer) if @buffer;
     }
   }