You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by do...@apache.org on 2011/05/16 02:14:06 UTC

svn commit: r1103581 - in /spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen: generate-new-scores lock-scores

Author: dos
Date: Mon May 16 00:14:06 2011
New Revision: 1103581

URL: http://svn.apache.org/viewvc?rev=1103581&view=rev
Log:
use scores from 72_active.cf (even commented out ones) to set abs max score values

Modified:
    spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen/generate-new-scores
    spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen/lock-scores

Modified: spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen/generate-new-scores
URL: http://svn.apache.org/viewvc/spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen/generate-new-scores?rev=1103581&r1=1103580&r2=1103581&view=diff
==============================================================================
--- spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen/generate-new-scores (original)
+++ spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen/generate-new-scores Mon May 16 00:14:06 2011
@@ -148,6 +148,8 @@ cd ../..
 # copy the support scripts to masses/ of the scoreset's checkout; this lets us
 # contain all the new score generation scripts in their own directory and keeps
 # us from having to pass the checkout path as an argument to each of the scripts
+# NOTE: lock-scores now uses existing scores (even commented out) in 72_active.cf
+# as absolute maximum values to be inserted in tmp/ranges.data
 cp lock-scores trunk-new-rules-set$SCORESET/masses/lock-scores
 cp extract-new-scores trunk-new-rules-set$SCORESET/masses/extract-new-scores
 cp add-hitless-active-to-freqs trunk-new-rules-set$SCORESET/masses/add-hitless-active-to-freqs

Modified: spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen/lock-scores
URL: http://svn.apache.org/viewvc/spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen/lock-scores?rev=1103581&r1=1103580&r2=1103581&view=diff
==============================================================================
--- spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen/lock-scores (original)
+++ spamassassin/trunk/rulesrc/sandbox/dos/new-rule-score-gen/lock-scores Mon May 16 00:14:06 2011
@@ -8,6 +8,9 @@
 # locks the score ranges for the base release rules to their original scores
 # from 50_scores.cf
 #
+# the script also uses existing scores in 72_active.cf (even commented ones)
+# to set the absolute min or max score in the ranges.data file
+#
 # if called with a 1 parameter new rules that aren't in the most current copy
 # of the active.list file will be locked to zero so that the GA can ignore
 # rules that aren't in the most current update (this is used for zeroing rules
@@ -37,6 +40,7 @@ use warnings;
 my $scoreset = 0; # default
 
 my %rulescores;
+my %newrulescores;
 my %currently_active;
 
 my $only_currently_active_rules = (defined $ARGV[0] && $ARGV[0] == 1 ? 1 : 0);
@@ -66,6 +70,21 @@ while(<ORIG>) {
 }
 close ORIG;
 
+open(ORIG, "../rules/72_active.cf") or die "Cannot open original score file: $!";
+while(<ORIG>) {
+  if (/^(?:\#\s*)?score/) {
+    /^(?:\#\s*)?score\s+(\S+)\s+(-?[\d.]+)(?:\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+))?/;
+    my @scores;
+    if (defined $3) {
+      push @scores, ($2, $3, $4, $5);
+    } else {
+      push @scores, ($2, $2, $2, $2);
+    }
+    $newrulescores{$1} = $scores[$scoreset];
+  }
+}
+close ORIG;
+
 if ($only_currently_active_rules) {
   open(ACTIVE, "../rules-current/active.list") or die "Cannot open rules-current/active.list: $!";
   while(<ACTIVE>) {
@@ -77,15 +96,24 @@ if ($only_currently_active_rules) {
 open(ORIG, "tmp/ranges.data") or die "Cannot open original range.data file: $!";
 open(NEW, ">tmp/ranges.data-new") or die "Cannot open range.data-new file: $!";
 while (<ORIG>) {
-  if (/^(?:(?:-?[\d.]+) ){3}(\S+)$/) {
-    if (defined $rulescores{$1}) {
-      print NEW "$rulescores{$1} $rulescores{$1} 0 $1\n";
+#  if (/^(?:(?:-?[\d.]+) ){3}(\S+)$/) {
+  if (/^(-?[\d.]+) (-?[\d.]+) (-?[\d.]+) (\S+)$/) {
+    if (defined $rulescores{$4}) {
+      print NEW "$rulescores{$4} $rulescores{$4} 0 $4\n";
     } else {
       if ($only_currently_active_rules) {
-        if (exists $currently_active{$1}) {
-          print NEW $_;
+        if (exists $currently_active{$4}) {
+          if (defined $newrulescores{$4}) {
+            if ($newrulescores{$4} > 0) {
+              print NEW "0 $newrulescores{$4} $3 $4\n"
+            } else {
+              print NEW "$newrulescores{$4} 0 $3 $4\n"
+            }
+          } else {
+            print NEW $_;
+          }
         } else {
-          print NEW "0 0 0 $1\n";
+          print NEW "0 0 0 $4\n";
         }
       } else {
         print NEW $_;