Gnus development mailing list
 help / color / mirror / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
Cc: Max Froumentin <max@lapin-bleu.net>, ding@gnus.org
Subject: Re: displaying arbitrary headers in summary
Date: Thu, 06 Nov 2003 14:58:14 -0500	[thread overview]
Message-ID: <4nsml12rs9.fsf@koz.bwh.harvard.edu> (raw)
In-Reply-To: <87islx1hsg.fsf@mulligatwani.msrl.com> (Michael Shields's message of "Thu, 06 Nov 2003 18:19:27 +0000")

On Thu, 06 Nov 2003, shields@msrl.com wrote:

> In message <87znf9d6i8.fsf@w3.org>,
> Max Froumentin <max@lapin-bleu.net> wrote:
>> Basically, I'd like to display the spamassassin score of each
>> article in each line of the summary buffer. It's probably not easy
>> since the content of the X-Spam-Status is not in the .now file by
>> default, but maybe there's a way to put it in there.
> 
> Here is one approach, along with a function that sorts by spam
> score:
> 
> (add-to-list 'nnmail-extra-headers 'X-Spam-Status)
> (defun gnus-article-spamassassin-score (header)
>   "Return the Spamassassin score of this article, as a string."
>   (gnus-replace-in-string
>    (gnus-replace-in-string
>     (gnus-extra-header 'X-Spam-Status header)
>     ".*hits=" "")
>    " .*" ""))
> (defun gnus-user-format-function-s (header)
>   (gnus-article-spamassassin-score header))
> (defun gnus-article-sort-by-spam-status (h1 h2)
>   "Sort articles by Spamassassin score."
>   (< (string-to-number (gnus-article-spamassassin-score h1))
>      (string-to-number (gnus-article-spamassassin-score h2))))

Can this go into spam.el, to be turned on by default for Bogofilter
and spam-use-regex (SpamAssassin) users if the users request it?  It
seems reasonable that the X-Spam-Status and similar headers should be
handled for summary formats, etc. by spam.el.

Maybe it can interface with the existing scoring functions for
Bogofilter.  I've been thinking about uniform weighted scoring for
spam.el - something that will always score between -1 and 1.  For
instance, SA scores, which can be between -inf. and inf. could be
weighted like so:

;;; assuming a range from -1 to 1
(defun normalize (score &optional offset)
  (let* ((score (float score))
	 (offset (if offset (float offset) 0))
	 (offset-score (- score offset)))
    (if (zerop offset-score)
	0
      (let* ((absolute-weighted-score (/ 2 offset-score))
	     (adjustment (if (> offset-score 0) 1 -1)))
	(- adjustment absolute-weighted-score)))))

What do you think?.

> Now you can use "%us" in your gnus-summary-line-format to display
> the spam score.  You could add to your spamtrap folder's group
> parameters:
> 
>  (gnus-summary-line-format "%U%R%z%I%(%[%6us: %-23,23f%]%) %s\n")
>  (gnus-article-sort-functions
>   '(gnus-article-sort-by-spam-status))
> 
> This displays the score for each article, and also puts the most
> likely false positives at the top.

Looks very useful!  I don't think any of this belongs in spam.el of
course, but it should probably go in the manual if we add your
formatting and headers code above.

Ted



  reply	other threads:[~2003-11-06 19:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-06 12:30 Max Froumentin
2003-11-06 18:19 ` Michael Shields
2003-11-06 19:58   ` Ted Zlatanov [this message]
2003-11-06 20:20     ` Michael Shields
2003-11-06 21:00       ` Ted Zlatanov
2003-11-13 17:32   ` making bogofilter write spam headers? Bill White
2003-11-13 18:07     ` Ted Zlatanov
2003-11-13 18:24       ` Bill White

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4nsml12rs9.fsf@koz.bwh.harvard.edu \
    --to=tzz@lifelogs.com \
    --cc=ding@gnus.org \
    --cc=max@lapin-bleu.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).