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

Modified Files:
        SpamFilter.h 
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.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/SpamFilter.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -u -2 -r1.1 -r1.2
--- SpamFilter.h        8 Jul 2004 15:22:23 -0000       1.1
+++ SpamFilter.h        10 Jul 2004 20:26:45 -0000      1.2
@@ -39,16 +39,16 @@
       Mark the message as spam.
 
-      This method is used for training the spam filter and also for correcting
-      its mistakes.
+      This method is used for correcting spam filter mistakes, see Train() for
+      training the spam filter.
 
       @param msg the spam message
     */
    static void ClassifyAsSpam(const Message& msg)
-      { ReclassifyAsSpam(msg, true); }
+      { Reclassify(msg, true); }
 
    /**
       Mark the message as non-spam.
 
-      Unlike ClassifyAsSpam() this is normally only used to correct mistakes,
+      Like ClassifyAsSpam() this is normally only used to correct mistakes,
       i.e. for reclassifying a false positive.
 
@@ -56,15 +56,32 @@
     */
    static void ClassifyAsHam(const Message& msg)
-      { ReclassifyAsSpam(msg, false); }
+      { Reclassify(msg, false); }
 
    /**
       Reclassify the message as either spam or ham.
 
-      Common part of ClassifyAsSpam/Ham()
+      Common part of ClassifyAsSpam/Ham().
+
+      Note that this should only be used if the spam filter had accidentally
+      detected that the message was a spam, not to train it.
+
 
       @param msg the message to reclassify
       @param isSpam if true, reclassify as spam, otherwise as ham
     */
-   static void ReclassifyAsSpam(const Message& msg, bool isSpam);
+   static void Reclassify(const Message& msg, bool isSpam);
+
+   /**
+      Train the spam filter using the specified spam or ham message.
+
+      Unlike Reclassify() which should only be used for the messages
+      which had been mistakenly misclassified by the filter, this method should
+      be used for the messages which had never been seen by the spam filter
+      before.
+
+      @param msg the message to train the filter with
+      @param isSpam if true, this as a spam, otherwise -- ham
+    */
+   static void Train(const Message& msg, bool isSpam);
 
    /**
@@ -72,9 +89,15 @@
 
       @param msg the message to check
-      @param probability if non NULL, return the probability of this message
-                         being a spam, may be NULL if caller not interested
+      @param params array containing the stringified options for the filters
+                    (each element is of the form "name=options" where "name" is
+                    the name of the filter and options depend on filter)
+      @param result place holder for the message explaining why the message was
+                    deemed to be spam, if the filter can tell it, ignored if
+                    the return value is false
       @return true if the message is deemed to be a spam, false otherwise
     */
-   static bool CheckIfSpam(const Message& msg, float *probability = NULL);
+   static bool CheckIfSpam(const Message& msg,
+                           const wxArrayString& params,
+                           String *result);
 
    /**
@@ -84,5 +107,5 @@
       memory used by the spam filters but can also be called during the program
       execution to force reloading of the spam filters during the next call to
-      ReclassifyAsSpam() or CheckIfSpam().
+      Reclassify() or CheckIfSpam().
     */
    static void UnloadAll();
@@ -97,5 +120,5 @@
       Loads all available spam filters.
 
-      This is called as needed by ReclassifyAsSpam()/CheckIfSpam(), no need to
+      This is called as needed by Reclassify()/CheckIfSpam(), no need to
       call it explicitly.
     */
@@ -116,9 +139,35 @@
    //@{
 
-   /// Reclassify a message as either spam or ham
-   virtual void Reclassify(const Message& msg, bool isSpam) = 0;
+   /**
+      Reclassify a message as either spam or ham.
+
+      This is used by the public Reclassify().
+    */
+   virtual void DoReclassify(const Message& msg, bool isSpam) = 0;
 
-   /// Process a message and return whether it is a spam
-   virtual bool Process(const Message& msg, float *probability) = 0;
+   /**
+      Train filter using this message.
+
+      This is used by the public Train().
+    */
+   virtual void DoTrain(const Message& msg, bool isSpam) = 0;
+
+   /**
+      Process a message and return whether it is a spam.
+
+      This is used by the public CheckIfSpam(). The parameter passed to it is
+      the RHS of the element in the params array passed to CheckIfSpam() having
+      the same name as this spam filter.
+    */
+   virtual bool DoCheckIfSpam(const Message& msg,
+                              const String& param,
+                              String *result) = 0;
+
+   /**
+      Return the internal name of this spam filter.
+
+      This method is implemented by DECLARE_SPAM_FILTER() macro below.
+    */
+   virtual const wxChar *GetName() const = 0;
 
    //@}
@@ -157,4 +206,15 @@
 
 /**
+  This macro must be used in SpamFilter-derived class declaration.
+
+  It defines GetName() which returns the parameter of the macro.
+
+  There should be no semicolon after this macro.
+ */
+#define DECLARE_SPAM_FILTER(name)                                             \
+   public:                                                                    \
+      virtual const wxChar *GetName() const { return _T(name); }
+
+/**
   This macro must be used in the .cpp file containing the implementation of a
   spam filter.



-------------------------------------------------------
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