+2003-01-10 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * spam.el (spam-use-stat): new variable
+ (spam-group-spam-processor-stat-p)
+ (spam-group-ham-processor-stat-p): new convenience functions
+ (spam-summary-prepare-exit): add spam/ham processors to sequence
+ (spam-list-of-checks): add spam-use-stat to list of checks
+ (spam-split): conditionally load the spam-stat tables
+ (spam-stat-register-spam-routine, spam-stat-register-ham-routine,
+ spam-check-ifile): new functions
+
+ * spam-stat.el (spam-stat): typo fix
+ (spam-stat-install-hooks): new variable
+ (spam-stat-split-fancy-spam-group): added documentation clarification
+ (spam-stat-split-fancy-spam-threshhold): new variable
+ (spam-stat-install-hooks): make hooks conditional
+ (spam-stat-split-fancy): use spam-stat-split-fancy-spam-threshhold
+
+ * gnus.el (gnus-group-ham-exit-processor-stat, spam-process): add
+ spam-stat ham/spam processor symbols
+
2003-01-10 Lars Magne Ingebrigtsen <larsi@gnus.org>
* gnus-start.el (gnus-read-newsrc-el-file): Make sure the .eld
"The ifile summary exit spam processor.
Only applicable to spam groups.")
+(defvar gnus-group-spam-exit-processor-stat "stat"
+ "The spam-stat summary exit spam processor.
+Only applicable to spam groups.")
+
(defvar gnus-group-spam-exit-processor-bogofilter "bogofilter"
"The Bogofilter summary exit spam processor.
Only applicable to spam groups.")
"The ifile summary exit ham processor.
Only applicable to non-spam (unclassified and ham) groups.")
+(defvar gnus-group-ham-exit-processor-stat "stat-ham"
+ "The spam-stat summary exit ham processor.
+Only applicable to non-spam (unclassified and ham) groups.")
+
(defvar gnus-group-ham-exit-processor-whitelist "whitelist"
"The whitelist summary exit ham processor.
Only applicable to non-spam (unclassified and ham) groups.")
(list :tag "Spam Summary Exit Processor Choices"
(set
(variable-item gnus-group-spam-exit-processor-ifile)
+ (variable-item gnus-group-spam-exit-processor-stat)
(variable-item gnus-group-spam-exit-processor-bogofilter)
(variable-item gnus-group-spam-exit-processor-blacklist)
(variable-item gnus-group-ham-exit-processor-ifile)
+ (variable-item gnus-group-ham-exit-processor-stat)
(variable-item gnus-group-ham-exit-processor-whitelist)
(variable-item gnus-group-ham-exit-processor-BBDB))))
:function-document
(regexp :tag "Group Regexp")
(set :tag "Spam/Ham Summary Exit Processor"
(variable-item gnus-group-spam-exit-processor-ifile)
+ (variable-item gnus-group-spam-exit-processor-stat)
(variable-item gnus-group-spam-exit-processor-bogofilter)
(variable-item gnus-group-spam-exit-processor-blacklist)
(variable-item gnus-group-ham-exit-processor-ifile)
+ (variable-item gnus-group-ham-exit-processor-stat)
(variable-item gnus-group-ham-exit-processor-whitelist)
(variable-item gnus-group-ham-exit-processor-BBDB))))
:parameter-document
"Statistical spam detection for Emacs.
Use the functions to build a dictionary of words and their statistical
distribution in spam and non-spam mails. Then use a function to determine
-wether a buffer contains spam or not."
+whether a buffer contains spam or not."
:group 'gnus)
(defcustom spam-stat-file "~/.spam-stat.el"
:type 'file
:group 'spam-stat)
+(defcustom spam-stat-install-hooks t
+ "Whether spam-stat should install its hooks in Gnus.
+This is set to nil if you use spam-stat through spam.el."
+ :type 'boolean
+ :group 'spam-stat)
+
(defcustom spam-stat-unknown-word-score 0.2
"The score to use for unknown words.
Also used for words that don't appear often enough."
(defcustom spam-stat-split-fancy-spam-group "mail.spam"
"Name of the group where spam should be stored, if
-`spam-stat-split-fancy' is used in fancy splitting rules."
+`spam-stat-split-fancy' is used in fancy splitting rules. Has no
+effect when spam-stat is invoked through spam.el."
:type 'string
:group 'spam-stat)
+(defcustom spam-stat-split-fancy-spam-threshhold 0.9
+ "Spam score threshhold in spam-stat-split-fancy."
+ :type 'number
+ :group 'spam-stat)
+
(defvar spam-stat-syntax-table
(let ((table (copy-syntax-table text-mode-syntax-table)))
(modify-syntax-entry ?- "w" table)
(set-buffer gnus-original-article-buffer)
(spam-stat-store-current-buffer)))
-(add-hook 'nnmail-prepare-incoming-message-hook
- 'spam-stat-store-current-buffer)
-(add-hook 'gnus-select-article-hook
- 'spam-stat-store-gnus-article-buffer)
+(when spam-stat-install-hooks
+ (add-hook 'nnmail-prepare-incoming-message-hook
+ 'spam-stat-store-current-buffer)
+ (add-hook 'gnus-select-article-hook
+ 'spam-stat-store-gnus-article-buffer))
;; Data -- not using defstruct in order to save space and time
(progn
(set-buffer spam-stat-buffer)
(goto-char (point-min))
- (when (> (spam-stat-score-buffer) 0.9)
+ (when (> (spam-stat-score-buffer) spam-stat-split-fancy-spam-threshhold)
(when (boundp 'nnmail-split-trace)
(mapc (lambda (entry)
(push entry nnmail-split-trace))
:type 'boolean
:group 'spam)
+(defcustom spam-use-stat nil
+ "Whether spam-stat should be used by spam-split."
+ :type 'boolean
+ :group 'spam)
+
(defcustom spam-split-group "spam"
"Group name where incoming spam should be put by spam-split."
:type 'string
(defun spam-group-ham-processor-ifile-p (group)
(spam-group-processor-p group 'gnus-group-ham-exit-processor-ifile))
+(defun spam-group-spam-processor-stat-p (group)
+ (spam-group-processor-p group 'gnus-group-spam-exit-processor-stat))
+
+(defun spam-group-ham-processor-stat-p (group)
+ (spam-group-processor-p group 'gnus-group-ham-exit-processor-stat))
+
(defun spam-group-ham-processor-whitelist-p (group)
(spam-group-processor-p group 'gnus-group-ham-exit-processor-whitelist))
(spam-group-spam-processor-ifile-p gnus-newsgroup-name))
(spam-ifile-register-spam-routine))
+ (when (spam-group-spam-processor-stat-p gnus-newsgroup-name)
+ (spam-stat-register-spam-routine))
+
(when (spam-group-spam-processor-bogofilter-p gnus-newsgroup-name)
(spam-blacklist-register-routine))
(spam-whitelist-register-routine))
(when (spam-group-ham-processor-ifile-p gnus-newsgroup-name)
(spam-ifile-register-ham-routine))
+ (when (spam-group-ham-processor-stat-p gnus-newsgroup-name)
+ (spam-stat-register-ham-routine))
(when (spam-group-ham-processor-BBDB-p gnus-newsgroup-name)
(spam-BBDB-register-routine)))
(spam-use-whitelist . spam-check-whitelist)
(spam-use-BBDB . spam-check-BBDB)
(spam-use-ifile . spam-check-ifile)
+ (spam-use-stat . spam-check-stat)
(spam-use-blackholes . spam-check-blackholes)
(spam-use-bogofilter . spam-check-bogofilter))
"The spam-list-of-checks list contains pairs associating a parameter
See the Info node `(gnus)Fancy Mail Splitting' for more details."
(interactive)
+
+ ;; load the spam-stat tables if needed
+ (when spam-use-stat (spam-stat-load))
(let ((list-of-checks spam-list-of-checks)
decision)
(setq return category)
;; else, if spam-ifile-all-categories is not set...
(when (string-equal spam-ifile-spam-category category)
- ;; always accept the ifile category
(setq return spam-split-group))))))
return))
(spam-get-article-as-string article) nil))))
\f
+;;;; spam-stat
+
+(condition-case nil
+ (progn
+ (let ((spam-stat-install-hooks nil))
+ (require 'spam-stat))
+
+ (defun spam-check-stat ()
+ "Check the spam-stat backend for the classification of this message"
+ (let ((spam-stat-split-fancy-spam-group spam-split-group) ; override
+ (spam-stat-buffer (buffer-name)) ; stat the current buffer
+ category return)
+ (spam-stat-split-fancy)))
+
+ (defun spam-stat-register-spam-routine ()
+ (spam-generic-register-routine
+ (lambda (article)
+ (let ((article-string (spam-get-article-as-string article)))
+ (with-temp-buffer
+ (insert-string article-string)
+ (spam-stat-buffer-is-spam))))
+ nil)
+ (spam-stat-save))
+
+ (defun spam-stat-register-ham-routine ()
+ (spam-generic-register-routine
+ nil
+ (lambda (article)
+ (let ((article-string (spam-get-article-as-string article)))
+ (with-temp-buffer
+ (insert-string article-string)
+ (spam-stat-buffer-is-non-spam)))))
+ (spam-stat-save)))
+
+ (file-error (progn
+ (defalias 'spam-stat-register-ham-routine 'ignore)
+ (defalias 'spam-stat-register-spam-routine 'ignore)
+ (defalias 'spam-stat-buffer-is-spam 'ignore)
+ (defalias 'spam-stat-buffer-is-non-spam 'ignore)
+ (defalias 'spam-stat-split-fancy 'ignore)
+ (defalias 'spam-stat-load 'ignore)
+ (defalias 'spam-stat-save 'ignore)
+ (defalias 'spam-check-stat 'ignore))))
+
+\f
+
;;;; Blacklists and whitelists.
(defvar spam-whitelist-cache nil)