From 6b995a4cc29d045bd3d696a3646ed7e343f3daaf Mon Sep 17 00:00:00 2001 From: Jesper Harder Date: Wed, 21 Jan 2004 02:00:08 +0000 Subject: [PATCH] (spam-stat-test-directory): New optional argument displays a list of files detected. Suggested by Andrew Cohen . --- lisp/ChangeLog | 8 +++++++- lisp/spam-stat.el | 28 ++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 65a8a5a85..3dba53393 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2004-01-21 Jesper Harder + + * spam-stat.el (spam-stat-test-directory): New optional argument + displays a list of files detected. Suggested by Andrew Cohen + . + 2004-01-20 Teodor Zlatanov * spam.el (gnus-summary-mode-map): make spam-generic-score the @@ -36,7 +42,7 @@ 2004-01-20 Jesper Harder - * spam-stat.el (spam-stat-to-hash-table): Use :size argument in + * spam-stat.el (spam-stat-to-hash-table): Use :size keyword in make-hash-table. 2004-01-19 Katsumi Yamaoka diff --git a/lisp/spam-stat.el b/lisp/spam-stat.el index 8464c2b88..97aa16047 100644 --- a/lisp/spam-stat.el +++ b/lisp/spam-stat.el @@ -504,13 +504,19 @@ check the variable `spam-stat-score-data'." (interactive) (hash-table-count spam-stat)) -(defun spam-stat-test-directory (dir) +(defun spam-stat-test-directory (dir &optional verbose) "Test all the regular files in directory DIR for spam. If the result is 1.0, then all files are considered spam. If the result is 0.0, non of the files is considered spam. -You can use this to determine error rates." - (interactive "D") +You can use this to determine error rates. + +If VERBOSE is non-nil display names of files detected as spam or +non-spam in a temporary buffer. If it is the symbol `ham', +display non-spam files; otherwise display spam files." + (interactive "DDirectory: ") (let* ((files (directory-files dir t "^[^.]")) + display-files + buffer-score (total (length files)) (score 0.0); float (max (/ total 100.0)); float @@ -521,12 +527,22 @@ You can use this to determine error rates." (file-regular-p f) (> (nth 7 (file-attributes f)) 0)) (setq count (1+ count)) - (message "Reading %.2f%%, score %.2f%%" - (/ count max) (/ score count)) + (message "Reading %.2f%%, score %.2f" + (/ count max) (/ score count)) (insert-file-contents f) - (when (> (spam-stat-score-buffer) 0.9) + (setq buffer-score (spam-stat-score-buffer)) + (when (> buffer-score 0.9) (setq score (1+ score))) + (when verbose + (if (> buffer-score 0.9) + (unless (eq verbose 'ham) (push f display-files)) + (when (eq verbose 'ham) (push f display-files)))) (erase-buffer)))) + (when display-files + (with-output-to-temp-buffer "*spam-stat results*" + (dolist (file display-files) + (princ file) + (terpri)))) (message "Final score: %d / %d = %f" score total (/ score total)))) ;; Shrinking the dictionary -- 2.25.1