#lang scheme
(require mzlib/contract mzlib/etc mzlib/pregexp net/mime (prefix-in srfi-date: srfi/19)
)
(define (parse-emails port)
(read-string 10000 port))
(regexp-match-positions #px"(?im:^From .*\\d{4})"
(call-with-input-file
(string->path "/Users/stephen/Desktop/2008-June.txt")
parse-emails
)
)
(call-with-input-file
(string->path "/Users/stephen/Desktop/2008-June.txt")
(lambda (i) (regexp-match-positions #px"(?im:^From .*\\d{4}$)" i)))
(call-with-input-file
(string->path "/Users/stephen/Desktop/2008-June.txt")
(lambda (i) (regexp-match* #px"(?im:^From .*\\d{4}$)" i)))
(regexp-match* #rx"(?im:^-[0-9]+)" "a-1232
878sdf
-e2q
-43
-d
-231
erw2-3
4b")
(define (addresses-string-split string)
(regexp-split #px",\\s*" string))
(addresses-string-split "michael.legler@enron.com")
(addresses-string-split "julie.gomez@enron.com, jim.schwieger@enron.com")
(addresses-string-split "klexplore@aol.com")
(define (rfc822datestring->time-utc date-string)
(srfi-date:date->time-utc (srfi-date:string->date date-string "~a, ~d ~b ~Y")))
(rfc822datestring->time-utc "Mon, 28 Nov 2000 23:15:00 -0800 (PST)")
(rfc822datestring->time-utc "Mon, 27 Nov 2000 23:15:00 -0800 (PST)")
(rfc822datestring->time-utc "Mon, 25 Nov 2000 23:16:00 -0800 (PST)")
(define (time-range? rfc822 rfc822start rfc822end)
(let ((time (rfc822datestring->time-utc rfc822) )
(start (rfc822datestring->time-utc rfc822start))
(end (rfc822datestring->time-utc rfc822end)))
(and (srfi-date:time<=? start time) (srfi-date:time<=? time end))))
(srfi-date:time-second (srfi-date:time-difference
(rfc822datestring->time-utc "Mon, 27 Nov 2000 23:15:00 -0800 (PST)")
(rfc822datestring->time-utc "Mon, 28 Nov 2000 23:16:00 -0800 (PST)")
))
(time-range? "Mon, 28 Nov 2000 23:15:00 -0800 (PST)"
"Mon, 25 Nov 2000 23:15:00 -0800 (PST)" "Mon, 29 Nov 2000 23:15:00 -0800 (PST)")
(time-range? "Mon, 28 Nov 2000 23:15:00 -0800 (PST)"
"Mon, 28 Nov 2000 23:15:00 -0800 (PST)" "Mon, 28 Nov 2000 23:15:00 -0800 (PST)")