+sub learn {
+ my ($options,$opts,$config,$argv) = @_;
+ for my $bug_num (@{$argv}) {
+ my $spam = Debbugs::Log::Spam->new(bug_num => $bug_num) or
+ die "Unable to open bug log spam for $bug_num";
+ foreachmsg(sub {
+ my ($bn,$rec,$mid) = @_;
+ my $score;
+ if ($spam->is_spam($mid)) {
+ $score //=
+ spam_score($rec,$options->{spamc},
+ [@{$options->{spamc_opts}},
+ '-L','spam'
+ ]
+ );
+ print STDERR "learning spam" if $DEBUG;
+ } elsif ($spam->is_ham($mid)) {
+ $score //=
+ spam_score($rec,$options->{spamc},
+ [@{$options->{spamc_opts}},
+ '-L','ham'
+ ]
+ );
+ print STDERR "learning ham" if $DEBUG;
+ } else {
+ print STDERR "not learning" if $DEBUG;
+ }
+ print STDERR " from $mid" if $DEBUG;
+ },
+ $bug_num
+ );
+ }
+}
+