From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/86405 Path: news.gmane.org!not-for-mail From: Dan Christensen Newsgroups: gmane.emacs.gnus.general Subject: Re: training spam filter Date: Tue, 15 Dec 2015 12:17:44 -0500 Message-ID: <87a8pbk4w7.fsf@uwo.ca> References: <87k2ogn0k1.fsf@uwo.ca> <87vb7zyd0g.fsf@roche-blanche.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1450199955 393 80.91.229.3 (15 Dec 2015 17:19:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Dec 2015 17:19:15 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M34637@lists.math.uh.edu Tue Dec 15 18:19:03 2015 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from lists1.math.uh.edu ([129.7.128.208]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a8tFd-0007oK-Nw for ding-account@gmane.org; Tue, 15 Dec 2015 18:19:01 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.85) (envelope-from ) id 1a8tEk-0001yl-AI; Tue, 15 Dec 2015 11:18:06 -0600 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by lists1.math.uh.edu with esmtps (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.85) (envelope-from ) id 1a8tEg-0001yI-VO for ding@lists.math.uh.edu; Tue, 15 Dec 2015 11:18:03 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1.2:DHE-RSA-AES128-SHA:128) (Exim 4.85) (envelope-from ) id 1a8tEf-0004g1-JJ for ding@lists.math.uh.edu; Tue, 15 Dec 2015 11:18:02 -0600 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1a8tEd-00011g-HT for ding@gnus.org; Tue, 15 Dec 2015 18:17:59 +0100 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1a8tEa-000609-5I for ding@gnus.org; Tue, 15 Dec 2015 18:17:56 +0100 Original-Received: from cpe0c473df46331-cm0c473df46330.cpe.net.cable.rogers.com ([99.255.248.224]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 15 Dec 2015 18:17:56 +0100 Original-Received: from jdc by cpe0c473df46331-cm0c473df46330.cpe.net.cable.rogers.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 15 Dec 2015 18:17:56 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: ding@gnus.org Original-Lines: 65 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cpe0c473df46331-cm0c473df46330.cpe.net.cable.rogers.com User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/24.3 (gnu/linux) Mail-Copies-To: never Cancel-Lock: sha1:yeyyOjSYFo14iF/uqblLo6di3dM= X-Spam-Score: -2.9 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:86405 Archived-At: On Dec 15, 2015, Peter Münster wrote: > On Mon, Dec 14 2015, Dan Christensen wrote: > >> I currently have a keystroke that trains my spam filter, and moves the >> article away, > > Could you post that piece of code please? It's below. Dan ; This is copied from someone else, and then modified by me. ; Search for *** below for where customization is needed. (setq rgb/gnus-spam-groups '("nnfolder:spam" "nnimap+foo:spam")) (defun rgb/gnus-treat-ham-or-spam (&optional n) "Handle SpamAssassin misses (in ham groups) and false positives (if in spam group)" (interactive "P") (let* ((ham-or-spam (if (member gnus-newsgroup-name rgb/gnus-spam-groups) "ham" "spam")) (prompt (format "Treating article %%s as %s...%%s" ham-or-spam)) (pipe (format "sa --%s" ham-or-spam)) ; Where to move the message after processing: *** (group (if (equal ham-or-spam "ham") "nnimap+foo:Inbox" "nnimap+foo:spam"))) (save-excursion (dolist (article (gnus-summary-work-articles n)) (message prompt article "") (gnus-summary-goto-subject article) (gnus-summary-show-raw-article) (if (equal ham-or-spam "spam") (gnus-summary-mark-article article gnus-expirable-mark t) (gnus-summary-mark-article article gnus-unread-mark t)) ; t arg is a recent addition, to ensure article is raw: (gnus-summary-save-in-pipe pipe t) ;(message prompt article "done") ) (gnus-summary-move-article nil group))) (gnus-summary-expand-window) (gnus-summary-next-subject 1) (gnus-summary-recenter) (gnus-summary-position-point) (gnus-set-mode-line 'summary)) (define-key gnus-summary-mode-map [?$ ?$] 'rgb/gnus-treat-ham-or-spam) On the machine that runs spamassassin, ~/bin/sa contains: #!/bin/sh # Usage: cat message | sa --spam [or --ham] sa-learn $1 --no-sync On another machine, ~/bin/sa contains: *** #!/bin/sh # Usage: cat message | sa --spam [or --ham] ssh host.that.runs.spamassassin sa-learn $1 --no-sync