@prefix r: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix dt: <http://www.w3.org/2001/XMLSchema#> .

@prefix m: <http://www.w3.org/2000/10/swap/pim/email#> .

@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix str: <http://www.w3.org/2000/10/swap/string#>.

@prefix cal: <http://www.w3.org/2002/12/cal/the@@#>.

#@prefix ont: <http://www.w3.org/2002/07/owl#>.

@prefix k: <http://opencyc.sourceforge.net/daml/cyc.daml#>.

@prefix    : <lc-comment-status#>.
@prefix lcs: <lc-comment-status#>.

@prefix jh: <lc-jh29May#>.



k:TheYear2003 dt:gYear "2003".
k:April k:nameString "Apr"; :mm "04".
k:May k:nameString "May"; :mm "05".
k:June k:nameString "June"; :mm "06".

this log:forAll :MSG, :MSGJ, :WHAT, :WHATJ, :WHEN, :WHENJ.


{
  <lc-jh29May.n3>.log:semantics log:includes {
   :MSG jh:date :WHEN
  }.

  (:WHEN "\\w+, (\\w+) \\d+ \\d+") str:scrape ?MMM.
  (:WHEN "\\w+, \\w+ (\\d+) \\d+") str:scrape ?D.
  (:WHEN "\\w+, \\w+ \\d+ (\\d+)") str:scrape ?YYYY.

  # prepend "0" then take last 2 chars
  ?DD is str:scrape of (("0" ?D).str:concatenation "(..)$").

  ?YEAR dt:gYear ?YYYY.
  ?MONTH k:nameString ?MMM; :mm ?MM.

  (?YYYY "-" ?MM "-" ?DD) str:concatenation ?YMD.
  ?DAY log:uri
    ("http://www.w3.org/2002/12/cal/the@@#day" ?YMD).str:concatenation.
}
 => {
  ?DAY dt:date ?YMD; :dd ?DD; :called :WHEN.
  ?DAY :in ?MONTH.
  ?YEAR k:temporallySubsumes ?DAY.
 }.



this log:forAll :PJ, :VJ.

jh:note a :InterestingProperty.
jh:nominee a :InterestingProperty.

{
  :PJ a :InterestingProperty.

  # pick a day...
  ?DAY :dd ?DD; :called :WHENJ;
    is k:temporallySubsumes of [ dt:gYear ?YYYY];
    :in [ k:nameString ?MMM ].
        
  # pick the subject of a message jim talked about from that day
  <lc-jh29May.n3>.log:semantics log:includes {
   [ jh:date :WHENJ; jh:subject :WHATJ; :PJ :VJ ]
  }.

  # pick a message with matching subject...
  <webont-lc-comments.n3>.log:semantics log:includes {
    :MSG m:date :WHEN; m:subject :WHAT.
  }.
  :WHAT str:contains :WHATJ.

  # and matching date parts...
  (:WHEN "\\w+, \\d+ (\\w+) \\d+") str:scrape ?MMM.
  (:WHEN "\\w+, (\\d+) \\w+ \\d+") str:scrape ?D.
  (:WHEN "\\w+, \\d+ \\w+ (\\d+)") str:scrape ?YYYY.

  # prepend "0" then take last 2 chars
  ?DD is str:scrape of (("0" ?D).str:concatenation "(..)$").

  ?ARCH log:uri ("http://www.w3.org/mid/"
    (:MSG.log:uri "mid:(.*)").str:scrape).str:concatenation.
}
 => {
  :MSG m:date :WHEN; m:subject :WHAT;
    :PJ :VJ;
    :archive ?ARCH.
 }.

