You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by km...@apache.org on 2013/01/21 05:48:44 UTC

svn commit: r1436202 - in /spamassassin/trunk: lib/Mail/SpamAssassin/Conf.pm lib/Mail/SpamAssassin/Conf/Parser.pm lib/Mail/SpamAssassin/PerMsgStatus.pm lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm t/autolearn_force.t t/autolearn_force_fail.t

Author: kmcgrail
Date: Mon Jan 21 04:48:44 2013
New Revision: 1436202

URL: http://svn.apache.org/viewvc?rev=1436202&view=rev
Log:
cleaned up more with the autolearn_force code and worked on major autolearn bug - bug 5503

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm
    spamassassin/trunk/t/autolearn_force.t
    spamassassin/trunk/t/autolearn_force_fail.t

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=1436202&r1=1436201&r2=1436202&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Mon Jan 21 04:48:44 2013
@@ -4389,6 +4389,11 @@ sub get_description_for_rule {
 sub maybe_header_only {
   my($self,$rulename) = @_;
   my $type = $self->{test_types}->{$rulename};
+
+  if ($rulename =~ /AUTOLEARNTEST/i) {
+    dbg("config: auto-learn: $rulename - Test type is $self->{test_types}->{$rulename}.");
+  }
+ 
   return 0 if (!defined ($type));
 
   if (($type == $TYPE_HEAD_TESTS) || ($type == $TYPE_HEAD_EVALS)) {
@@ -4410,6 +4415,11 @@ sub maybe_header_only {
 sub maybe_body_only {
   my($self,$rulename) = @_;
   my $type = $self->{test_types}->{$rulename};
+
+  if ($rulename =~ /AUTOLEARNTEST/i) {
+    dbg("config: auto-learn: $rulename - Test type is $self->{test_types}->{$rulename}.");
+  }
+
   return 0 if (!defined ($type));
 
   if (($type == $TYPE_BODY_TESTS) || ($type == $TYPE_BODY_EVALS)

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm?rev=1436202&r1=1436201&r2=1436202&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm Mon Jan 21 04:48:44 2013
@@ -924,7 +924,8 @@ sub finish_parsing {
     # free up stuff we no longer need
     delete $conf->{tests};
     delete $conf->{priority};
-    delete $conf->{test_types};
+    #test_types are needed - see bug 5503
+    #delete $conf->{test_types};
   }
 }
 
@@ -1200,6 +1201,12 @@ sub add_test {
 
   $conf->{tests}->{$name} = $text;
   $conf->{test_types}->{$name} = $type;
+
+  if ($name =~ /AUTOLEARNTEST/i) {
+     dbg("config: auto-learn: $name has type $type = $conf->{test_types}->{$name} during add_test\n");
+  }
+
+  
   if ($type == $Mail::SpamAssassin::Conf::TYPE_META_TESTS) {
     $conf->{priority}->{$name} ||= 500;
   }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1436202&r1=1436201&r2=1436202&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Mon Jan 21 04:48:44 2013
@@ -455,12 +455,16 @@ sub _get_autolearn_points {
     # ignore tests with 0 score (or undefined) in this scoreset
     next if !$scores->{$test};
 
-    # Go ahead and add points to the proper locations - Changed to elsif because in testing, 
-    # I was getting both head and body.
-    if (!$self->{conf}->maybe_header_only ($test)) {
-      $self->{body_only_points} += $scores->{$test};
-    } elsif (!$self->{conf}->maybe_body_only ($test)) {
+    # Go ahead and add points to the proper locations 
+    # Changed logic because in testing, I was getting both head and body. Bug 5503
+    if ($self->{conf}->maybe_header_only ($test)) {
       $self->{head_only_points} += $scores->{$test};
+      dbg("learn: auto-learn: adding head_only points $scores->{$test}");
+    } elsif ($self->{conf}->maybe_body_only ($test)) {
+      $self->{body_only_points} += $scores->{$test};
+      dbg("learn: auto-learn: adding body_only points $scores->{$test}");
+    } else {
+      dbg("learn: auto-learn: not considered head or body scores: $scores->{$test}");
     }
 
     $points += $scores->{$test};

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm?rev=1436202&r1=1436201&r2=1436202&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm Mon Jan 21 04:48:44 2013
@@ -190,8 +190,8 @@ sub autolearn_discriminator {
 
     #Set a lower threshold of "just has to be spam" if autolearn_force was set on a rule
     if ($force_autolearn) {
-      $required_body_points = 0;
-      $required_head_points = 0;
+      $required_body_points = -99;
+      $required_head_points = -99;
       dbg("learn: auto-learn: autolearn_force flagged for a rule.  Removing seperate body and head point threshold.  Body Only Points: $body_only_points ($required_body_points req'd) / Head Only Points: $head_only_points ($required_head_points req'd)");
     } else {
       dbg("learn: auto-learn: autolearn_force not flagged for a rule. Body Only Points: $body_only_points ($required_body_points req'd) / Head Only Points: $head_only_points ($required_head_points req'd)");

Modified: spamassassin/trunk/t/autolearn_force.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/autolearn_force.t?rev=1436202&r1=1436201&r2=1436202&view=diff
==============================================================================
--- spamassassin/trunk/t/autolearn_force.t (original)
+++ spamassassin/trunk/t/autolearn_force.t Mon Jan 21 04:48:44 2013
@@ -17,9 +17,9 @@ q{ autolearn=spam } => 'autolearned as s
 
 tstprefs ('
 
-body	WEIGHT	/EVOLUTION PREVIEW RELEASE/
-score	WEIGHT	7.0
-tflags	WEIGHT	autolearn_force
+body	AUTOLEARNTEST_BODY	/EVOLUTION PREVIEW RELEASE/
+score	AUTOLEARNTEST_BODY	7.0
+tflags	AUTOLEARNTEST_BODY	autolearn_force
 
 use_bayes 1
 bayes_auto_learn 1

Modified: spamassassin/trunk/t/autolearn_force_fail.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/autolearn_force_fail.t?rev=1436202&r1=1436201&r2=1436202&view=diff
==============================================================================
--- spamassassin/trunk/t/autolearn_force_fail.t (original)
+++ spamassassin/trunk/t/autolearn_force_fail.t Mon Jan 21 04:48:44 2013
@@ -16,8 +16,9 @@ q{ autolearn=spam } => 'autolearned as s
 
 tstprefs ('
 
-header	WEIGHT	From =~ /@/
-score	WEIGHT	13.0
+header	 AUTOLEARNTEST_FROM_HEADER	From =~ /@/
+score	 AUTOLEARNTEST_FROM_HEADER	13.0
+describe AUTOLEARNTEST_FROM_HEADER	Test rule for Autolearning 
 
 use_bayes 1
 bayes_auto_learn 1