Update of /cvsroot/mahogany/M/src/mail
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25163/src/mail

Modified Files:
        SpamFilter.cpp 
Log Message:
1. renamed dspam.cpp to DspamFilter.cpp
2. moved built in heuristic headers-based spam filter to HeadersFilter
3. added SpamFilter::Train() and implemented it for dspam
4. renamed SpamFilter::ReclassifyAsSpam() to Reclassify(), added
   DECLARE_SPAM_FILTER() macro and changed CheckIfSpam() to return a
   string explaining why the message was deemed to be a spam


Index: SpamFilter.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/SpamFilter.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -2 -r1.2 -r1.3
--- SpamFilter.cpp      8 Jul 2004 22:07:19 -0000       1.2
+++ SpamFilter.cpp      10 Jul 2004 20:26:45 -0000      1.3
@@ -49,5 +49,5 @@
 
 /* static */
-void SpamFilter::ReclassifyAsSpam(const Message& msg, bool isSpam)
+void SpamFilter::Reclassify(const Message& msg, bool isSpam)
 {
    LoadAll();
@@ -55,10 +55,10 @@
    for ( SpamFilter *p = ms_first; p; p = p->m_next )
    {
-      p->Reclassify(msg, isSpam);
+      p->DoReclassify(msg, isSpam);
    }
 }
 
 /* static */
-bool SpamFilter::CheckIfSpam(const Message& msg, float *probability)
+void SpamFilter::Train(const Message& msg, bool isSpam)
 {
    LoadAll();
@@ -66,7 +66,55 @@
    for ( SpamFilter *p = ms_first; p; p = p->m_next )
    {
-      if ( p->Process(msg, probability) )
+      p->DoTrain(msg, isSpam);
+   }
+}
+
+/* static */
+bool
+SpamFilter::CheckIfSpam(const Message& msg,
+                        const wxArrayString& params,
+                        String *result)
+{
+   LoadAll();
+
+   // break down the parameters into names and parameters
+   wxSortedArrayString names;
+   wxArrayString values;
+   const size_t count = params.GetCount();
+   for ( size_t n = 0; n < count; n++ )
+   {
+      const wxString& param = params[n];
+      int pos = param.Find(_T('='));
+      if ( pos == wxNOT_FOUND )
+      {
+         wxLogDebug(_T("Invalid spam filter parameter \"%s\""), param.c_str());
+         continue;
+      }
+
+      // insert the value in the same position in values array as name is going
+      // to have in the names one (as it's sorted we don't know where will it
+      // be)
+      values.Insert(param.c_str() + pos + 1, names.Add(wxString(param, pos)));
+   }
+
+
+   // now try all filters in turn until one of them returns true
+   for ( SpamFilter *p = ms_first; p; p = p->m_next )
+   {
+      const String& name(p->GetName());
+
+      int n = names.Index(name);
+      String param;
+      if ( n != wxNOT_FOUND )
+         param = values[(size_t)n];
+
+      if ( p->DoCheckIfSpam(msg, param, result) )
+      {
+         if ( result )
+            *result = name + _T(": ") + *result;
+
          return true;
    }
+   }
 
    return false;



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to