~ubuntu-branches/ubuntu/utopic/spamassassin/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/Mail/SpamAssassin/BayesStore.pm

  • Committer: Bazaar Package Importer
  • Author(s): Noah Meyerhans
  • Date: 2010-01-26 22:53:12 UTC
  • mfrom: (1.1.13 upstream) (5.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100126225312-wkftb10idc1kz2aq
Tags: 3.3.0-1
* New upstream version.
* Switch to dpkg-source 3.0 (quilt) format

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
=head1 NAME
19
19
 
20
 
Mail::SpamAssassin::BayesStore - Bayesian Storage Module
 
20
Mail::SpamAssassin::BayesStore - Storage Module for default Bayes classifier
21
21
 
22
22
=head1 DESCRIPTION
23
23
 
24
24
This is the public API for the Bayesian store methods.  Any implementation of
25
 
the storage module must implement these methods.
 
25
the storage module for the default Bayes classifier must implement these methods.
26
26
 
27
27
=cut
28
28
 
31
31
use strict;
32
32
use warnings;
33
33
use bytes;
 
34
use re 'taint';
34
35
use Mail::SpamAssassin::Logger;
35
36
 
36
37
# TODO: if we ever get tuits, it'd be good to make these POD
42
43
 
43
44
=item new
44
45
 
45
 
public class (Mail::SpamAssassin::BayesStore) new (Mail::SpamAssassin::Bayes $bayes)
 
46
public class (Mail::SpamAssassin::BayesStore) new (Mail::SpamAssassin::Plugin::Bayes $bayes)
46
47
 
47
48
Description:
48
49
This method creates a new instance of the Mail::SpamAssassin::BayesStore
49
 
object.  You must pass in an instance of the Mail::SpamAssassin:Bayes object,
50
 
which is stashed for use throughout the module.
 
50
object.  You must pass in an instance of the Mail::SpamAssassin::Plugin::Bayes
 
51
object, which is stashed for use throughout the module.
51
52
 
52
53
=cut
53
54
 
88
89
 
89
90
Description:
90
91
This method reads any needed config variables from the configuration
91
 
object and then calls the Mail::SpamAssassin::Bayes read_db_configs method.
 
92
object and then calls the Mail::SpamAssassin::Plugin::Plugin::Bayes read_db_configs method.
92
93
 
93
94
=cut
94
95
 
209
210
  my ($self, $opts) = @_;
210
211
  my $ret;
211
212
 
 
213
  my $eval_stat;
212
214
  eval {
213
215
    local $SIG{'__DIE__'};      # do not run user die() traps in here
214
216
    if ($self->tie_db_writable()) {
215
217
      $ret = $self->expire_old_tokens_trapped ($opts);
216
218
    }
 
219
    1;
 
220
  } or do {
 
221
    $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
217
222
  };
218
 
  my $err = $@;
219
223
 
220
224
  if (!$self->{bayes}->{main}->{learn_caller_will_untie}) {
221
225
    $self->untie_db();
222
226
  }
223
227
 
224
 
  if ($err) {           # if we died, untie the dbs.
225
 
    warn "bayes: expire_old_tokens: $err\n";
 
228
  if (defined $eval_stat) {     # if we died, untie the dbs.
 
229
    warn "bayes: expire_old_tokens: $eval_stat\n";
226
230
    return 0;
227
231
  }
228
232
  $ret;
378
382
  if ($opts->{verbose}) {
379
383
    my $hapax_pc = ($num_hapaxes * 100) / $kept;
380
384
    my $lowfreq_pc = ($num_lowfreq * 100) / $kept;
381
 
    print "$msg\n$msg2\n";
382
 
    printf "token frequency: 1-occurrence tokens: %3.2f%%\n", $hapax_pc;
383
 
    printf "token frequency: less than 8 occurrences: %3.2f%%\n", $lowfreq_pc;
 
385
    print "$msg\n$msg2\n"  or die "Error writing: $!";
 
386
    printf "token frequency: 1-occurrence tokens: %3.2f%%\n", $hapax_pc
 
387
      or die "Error writing: $!";
 
388
    printf "token frequency: less than 8 occurrences: %3.2f%%\n", $lowfreq_pc
 
389
      or die "Error writing: $!";
384
390
  }
385
391
  else {
386
392
    dbg("bayes: $msg: $msg2");
630
636
public instance (\@) tok_get_all (@ @tokens)
631
637
 
632
638
Description:
633
 
This method retrieves the specified tokens (C<@tokens>) from storage and returns
634
 
an array ref of arrays spam count, ham acount and last access time.
 
639
This method retrieves the specified tokens (C<@tokens>) from storage and
 
640
returns an array ref of arrays spam count, ham count and last access time.
635
641
 
636
642
=cut
637
643
 
682
688
public instance (Integer, Integer) nspam_nham_get ()
683
689
 
684
690
Description:
685
 
This method retrieves the total number of spam and the total number of spam
 
691
This method retrieves the total number of spam and the total number of ham
686
692
currently under storage.
687
693
 
688
694
=cut
821
827
public instance (Boolean) backup_database ()
822
828
 
823
829
Description:
824
 
This method will dump the users database in a marchine readable format.
 
830
This method will dump the users database in a machine readable format.
825
831
 
826
832
=cut
827
833