[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mhc:01386] Re: mhc-import の時刻 guess の不具合



乃村です.

On Mon, 25 Jun 2001 16:56:54 +0900,
	KOIE Hidetaka (鯉江英隆) <hide@xxxxxxxx> said:

>     2001-06-23:01:02:03
> 
> という腐った文字列があった場合、23:01の候補と14:03の候補が出ます。
> これをguessできる必要はないのですが
> 疑問
>    (1) 01:02が出てこない
>    (2) なぜ02:03ではなくて14:03なのか

(1) は,isearch-forward-regexp して,
[0-9]+:[0-9]+ と入力して,C-s を連打すると,
01:02 が出てこないのと同じ理由です.
こいつは,おそらくマッチさせる必要はないと思います.

(2) は,8時より前に予定が入らないと踏んで,
08:00 より前の時刻は,午後に読み換えて,+12 している
からです.8 は,僕の生活スタイルに依存していて,
ソース中にもコメントしてあります.

僕は,これが具合がいいのですが,
これで困ったことある人がいますか?
あれば,カスタマイズ可能にします.

> コードみてもさっぱりなので
> これが潜在バグをつっついてくれることを期待しつつ
> 現象だけ報告させていただきます。

もっとすっきり書ければいいんですけど...

最後におまけとして,mhc-stat.el という,guess の性能を計る
ツールを付けます.下記を eval してもらって,*scratch* に移動して,
M-x mhc-stat-guess-check に,例えば, ~nom/Mail/schedule/2001 と
答えてみてください.

2001年の guess に関する失敗,成功の様子が分かります.
で,もしよければ,失敗する典型的な例について,
みなさんにフィードバックしていたければ嬉しいです.
--
nom

;;; mhc-stat.el -- Get statistics of MHC.

;; Author:  Yoshinari Nomura <nom@xxxxxxxxxxxxx>
;;
;; Created: 2001/06/25
;; Revised: $Date$
;;

;;;
;;; Commentary:
;;;

;; mhc-stat-guess reports the statistics of mhc-guess results.
;;
;;

;;;
;;; Code:
;;;

(require 'mhc-schedule)
(provide 'mhc-stat)

;; returns a path list in a directory recursively.
(defun mhc-stat/filename-recursively (dir &optional pattern)
  (message "Checking %s ... " dir)
  (let* ((dir    (expand-file-name dir))
	 (dirent (delete ".." (delete "." (directory-files dir))))
	 (ret    ()))
    (while dirent
      (setq path (expand-file-name (car dirent) dir))
      (cond
       ((and (file-regular-p  path)
	     (or (null pattern) (string-match pattern path)))
	(setq ret (cons path ret)))
       ((file-directory-p path)
	(setq ret (append (mhc-stat/filename-recursively path pattern) ret)))
       (t
	() ;; ignore
	))
      (setq dirent (cdr dirent)))
    (message "Checking %s ... done." dir)
    ret))

;;
;; reports guess results and answers.
;;
;; Each MHC file contains original e-mail (Question) and
;; X-SC-Day: (Answer) both. Using this info, check the 
;; guess errors.
;;
;; return: (gues-result . answer)
;;
;; (nil          . "1999-01-01") ... failed (guess has no idea)
;; ("1999-01-31" . "1999-01-01") ... failed (guess mismatch)
;; ("1999-01-01" . "1999-01-01") ... succeed
;; 'dont-care                    ... It is not inported article from a mail.
;; 'multi                        ... It contains multiple articles in a file.
;;
(defun mhc-stat/guess-check-one (filename)
  (let (sch guess)
    (save-excursion
      ;; setup buffer
      (set-buffer (mhc-get-buffer-create " *mhc-parse-file*"))
      (delete-region (point-min) (point-max))
      (mhc-insert-file-contents-as-coding-system
       mhc-default-coding-system filename)
      ;; guess.
      (if (setq guess (car (mhc-guess-date)))
	  (setq guess (mhc-guess-get-date guess)))

      ;; return answer and guess results.
      (if (not (mhc-header-get-value "From"))
	  'dont-care
	(setq sch (car (mhc-record-schedules
			(mhc-parse-buffer
			 (mhc-record-new filename)))))
	(if (mhc-logic-occur-multiple-p (mhc-schedule-condition sch))
	    'multi
	  (cons
	   (if guess (mhc-date-format guess "%04d-%02d-%02d" yy mm dd))
	   (mhc-date-format (car (aref (mhc-schedule-condition sch)  0))
			    "%04d-%02d-%02d" yy mm dd)))))))

;;
;; make guess report from a mhc directory.
;;
(defun mhc-stat-guess-check (dir)
  (interactive "D")
  (let ((path-list (mhc-stat/filename-recursively dir "/[0-9]+$"))
	(nomail-count 0) (multi-count 0) (ok-count 0) (ng-count 0))

    (while path-list
      (message (format "Checking %s ..." path))
      (setq guess-result (mhc-stat/guess-check-one (car path-list)))
      (cond
       ((eq 'dont-care guess-result)
	(setq nomail-count (1+ nomail-count))
	(setq status "NOMAIL"))
       ((eq 'multi guess-result)
	(setq multi-count (1+ multi-count))
	(setq status "MULTI"))
       ((equal (car guess-result) (cdr guess-result))
	(setq ok-count (1+ ok-count))
	(setq status "OK"))
       (t
	(setq ng-count (1+ ng-count))
	(setq status "NG")))

      (if (listp guess-result)
	  (insert (format "%-6s guess: %10s ans: %10s %s\n"
			  status
			  (car guess-result)
			  (cdr guess-result)
			  (car path-list)))
	(insert (format "%-6s guess: %10s ans: %10s %s\n"
			status "" "" (car path-list))))
      (setq path-list (cdr path-list)))
    (insert (format "TOTAL:  OK: %d, NG: %d, NOMAIL: %d MULTI: %d\n"
		    ok-count ng-count nomail-count multi-count))))

;;; Copyright Notice:

;; Copyright (C) 2001 Yoshinari Nomura. All rights reserved.
;; Copyright (C) 2001 MHC developing team. All rights reserved.

;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;; 
;; 1. Redistributions of source code must retain the above copyright
;;    notice, this list of conditions and the following disclaimer.
;; 2. Redistributions in binary form must reproduce the above copyright
;;    notice, this list of conditions and the following disclaimer in the
;;    documentation and/or other materials provided with the distribution.
;; 3. Neither the name of the team nor the names of its contributors
;;    may be used to endorse or promote products derived from this software
;;    without specific prior written permission.
;; 
;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS''
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
;; THE TEAM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
;; OF THE POSSIBILITY OF SUCH DAMAGE.

;;; mhc-stat.el ends here