You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2006/12/04 06:51:15 UTC

svn commit: r482087 - in /spamassassin/rules/trunk/sandbox/felicity: 70_other.cf sandbox-felicity.pm

Author: felicity
Date: Sun Dec  3 21:51:13 2006
New Revision: 482087

URL: http://svn.apache.org/viewvc?view=rev&rev=482087
Log:
add in potential eval replacement for TVD_STOCK1

Modified:
    spamassassin/rules/trunk/sandbox/felicity/70_other.cf
    spamassassin/rules/trunk/sandbox/felicity/sandbox-felicity.pm

Modified: spamassassin/rules/trunk/sandbox/felicity/70_other.cf
URL: http://svn.apache.org/viewvc/spamassassin/rules/trunk/sandbox/felicity/70_other.cf?view=diff&rev=482087&r1=482086&r2=482087
==============================================================================
--- spamassassin/rules/trunk/sandbox/felicity/70_other.cf (original)
+++ spamassassin/rules/trunk/sandbox/felicity/70_other.cf Sun Dec  3 21:51:13 2006
@@ -259,6 +259,16 @@
 body BASE64_LENGTH_79	eval:check_base64_length('79')
 body BASE64_LENGTH_80	eval:check_base64_length('80')
 body BASE64_LENGTH_90	eval:check_base64_length('90')
+
+
+# better results than TVD_STOCK1:
+# 19.869  22.6915   0.0000    1.000   1.00    1.00  TVD_STOCK_02
+# 12.248  13.9887   0.0000    1.000   0.83    1.00  TVD_STOCK_03
+#  9.861  11.2617   0.0000    1.000   0.67    1.00  TVD_STOCK1
+# 20.259  23.0657   0.5047    0.979   0.50    1.00  TVD_STOCK_01
+body TVD_STOCK_01    eval:check_stock_info('1')
+body TVD_STOCK_02    eval:check_stock_info('2')
+body TVD_STOCK_03    eval:check_stock_info('3')
 endif
 ########################################################################
 

Modified: spamassassin/rules/trunk/sandbox/felicity/sandbox-felicity.pm
URL: http://svn.apache.org/viewvc/spamassassin/rules/trunk/sandbox/felicity/sandbox-felicity.pm?view=diff&rev=482087&r1=482086&r2=482087
==============================================================================
--- spamassassin/rules/trunk/sandbox/felicity/sandbox-felicity.pm (original)
+++ spamassassin/rules/trunk/sandbox/felicity/sandbox-felicity.pm Sun Dec  3 21:51:13 2006
@@ -38,6 +38,7 @@
 
   # the important bit!
   $self->register_eval_rule ("check_base64_length");
+  $self->register_eval_rule("check_stock_info");
 
   return $self;
 }
@@ -71,6 +72,61 @@
   }
   
   return $result;
+}
+
+sub check_stock_info {
+  my ($self, $pms, $fulltext, $min) = @_;
+
+  $self->_check_stock_info($pms) unless (exists $pms->{stock_info});
+
+  if ($min == 0 || $pms->{stock_info} >= $min) {
+      return 1;
+  }
+  return 0;
+}
+
+sub _check_stock_info {
+  my ($self, $pms) = @_;
+  $pms->{stock_info} = 0;
+
+  # Find all multipart/alternative parts in the message
+  my @parts = $pms->{msg}->find_parts(qr@^text/plain$@i);
+  return if (!@parts);
+
+  # Go through each of the multipart parts
+  my %hits = ();
+  my $part = $parts[0];
+  my ($type, $rnd) = $part->rendered();
+  return unless $type;
+
+  foreach ( $rnd =~ /^\s*([^:\n]{3,30})\s*:\s*\S/mg ) {
+    my $str = lc $_;
+    $str =~ tr/a-z//cd;
+    #$str =~ s/([a-z])0([a-z])/$1o$2/g;
+
+    if ($str =~ /(
+      ^trad(?:e|ing)date|
+      company(?:name)?|
+      s\w?(?:t\w?o\w?c\w?k|y\w?m(?:\w?b\w?o\w?l)?)|
+      t(?:arget|icker)|
+      (?:opening|current)p(?:rice)?|
+      p(?:rojected|osition)|
+      expectations|
+      weeks?high|
+      marketperformance|
+      (?:year|week|month|day|price)(?:target|estimates?)|
+      sector|
+      r(?:ecommendation|ating)
+    )$/x) {
+      $hits{$1}++;
+      dbg("eval: stock info hit: $1");
+    }
+  }
+
+  $pms->{stock_info} = scalar keys %hits;
+  dbg("eval: stock info total: ".$pms->{stock_info});
+
+  return;
 }
 
 1;