[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OT: Newsgroup statistics howto?
From: |
Patrick Drechsler |
Subject: |
Re: OT: Newsgroup statistics howto? |
Date: |
Tue, 06 Jul 2004 13:47:22 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
Paul Johnson wrote on 06 Jul 2004 06:02:08 MET:
> This might be a little bit off-topic, however, I've been trying
> to find an easy way to get posting statistics for a newsgroup
> received via NNTP. Basically, something like statnews or
> NGStatsistics but not on a local spool. Is there a way?
Not shure if this is what you're looking for...:
--8<------------------------schnipp------------------------->8---
;;; --- Statistics --------------------------------------------------
;; Usage:
;; To use it, mark the region in the summary buffer you want
;; statistics for and execute `M-x stat'.
(defun stat (beg end)
(interactive "r")
(let (header from-list subject-list from subject (n 0) (chars 0))
(save-excursion
(goto-char beg)
(while (< (point) end)
(setq header (gnus-summary-article-header))
(incf n)
(incf chars (mail-header-chars header))
(setq from (gnus-extract-address-components (mail-header-from header)))
(setq from (or (car from) (cadr from)))
(if (assoc from from-list)
(incf (cdr (assoc from from-list)))
(push (cons from 1) from-list))
(setq subject (gnus-simplify-subject (mail-header-subject header)))
(if (assoc subject subject-list)
(incf (cdr (assoc subject subject-list)))
(push (cons subject 1) subject-list))
(forward-line)))
(setq from-list (sort from-list (lambda (a b) (> (cdr a) (cdr b)))))
(setq subject-list (sort subject-list (lambda (a b) (> (cdr a) (cdr b)))))
(switch-to-buffer-other-window (get-buffer-create "*stat*"))
(insert (format "Total number of posts: %i\n" n))
(insert (format "Average bytes/post: %f\n" (/ (float chars) n)))
(insert (format "Total number of posters: %i\n" (length from-list)))
(insert (format "Average posts/poster: %f\n\n" (stat-mean from-list)))
(stat-top from-list 20)
(insert (format "\nTotal number of subjects: %i\n" (length subject-list)))
(insert (format "Average posts/subject: %f\n\n" (stat-mean subject-list)))
(stat-top subject-list 20)))
(defun stat-mean (alist)
(let ((mean 0))
(dolist (x alist)
(incf mean (cdr x)))
(/ (float mean) (length alist))))
(defun stat-top (alist &optional n)
(dotimes (i (if (integerp n)
(min n (length alist))
(length alist)))
(insert (format "%4i %s\n"
(cdr (nth i alist))
(car (nth i alist))))))
--8<------------------------schnapp------------------------->8---
HTH,
Patrick
--
Math is like love -- a simple idea but it can get complicated.
--R. Drabek