eventsOnDay.n3
2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
@prefix dc: <http://purl.org/dc/elements/1.1/>.
<> dc:description """eventsOnDay -- find events on a given day
""",
"$Id: eventsOnDay.n3,v 1.2 2003/07/08 22:59:10 connolly Exp $".
@prefix ical: <http://www.w3.org/2002/12/cal/ical#>.
@prefix str: <http://www.w3.org/2000/10/swap/string#> .
@prefix os: <http://www.w3.org/2000/10/swap/os#> .
@prefix time: <http://www.w3.org/2000/10/swap/time#> .
@prefix math: <http://www.w3.org/2000/10/swap/math#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix k: <http://opencyc.sourceforge.net/daml/cyc.daml#>.
@prefix dt: <http://www.w3.org/2001/XMLSchema#>.
@prefix : <http://www.w3.org/2000/12/cal/eventsOnDay#>.
@prefix eon: <http://www.w3.org/2000/12/cal/eventsOnDay#>.
@prefix the: <http://www.w3.org/2002/12/cal/the@@#>.
##
# grab date from command line... use --with 2003-07-08
#
:arg :index "1", "2", "3", "4".
{
[ is :index of :arg] os:argv ?YMD.
?D log:uri
("http://www.w3.org/2002/12/cal/the@@#Day" ?YMD).str:concatenation.
} => { ?D a k:Date, k:CalendarDay, :CommandLineDay; dt:date ?YMD }.
####
# partition Vevents among several classes...
# a bit of RDFS...
@prefix s: <http://www.w3.org/2000/01/rdf-schema#>.
{ ?S [ s:domain ?C ] [] } => { ?S a ?C }.
{ ?E ical:dtstart [ ical:date [] ] } => { ?E a :AllDayEvent }.
{ ?E ical:dtstart [ ical:dateTime [] ] } => { ?E a :TimedEvent }.
ical:dtend s:domain :TimedEndEvent.
ical:duration s:domain :FixedDurationEvent.
ical:rrule s:domain :RecurringEvent.
#@@ hm... how to tell that something is *not* a recurring event...
###
# :TimedEvent, :TimedEndEvent
{
?D a k:CalendarDay.
?E.ical:dtstart.ical:dateTime str:startsWith ?D.dt:date.
}
=> { ?D k:temporalBoundsIntersect ?E }.
{
?D a k:CalendarDay; k:temporalBoundsIntersect ?E.
?E.ical:dtend.ical:dateTime str:startsWith ?D.dt:date.
}
=> { ?D k:temporallySubsumes ?E }.
###
# :TimedEvent, :FixedDurationEvent
#@@
###
# :FixedDurationEvent, :AllDayEvent.
{
?D a k:CalendarDay.
?E.ical:dtstart.ical:date str:notGreaterThan ?D.dt:date.
(?E.ical:duration "^P(\\d+)D$") str:scrape ?DUR.
(24 60 60) math:product ?SECS_PER_DAY.
(
(?D.dt:date.time:inSeconds ?SECS_PER_DAY).math:integerQuotient
(?E.ical:dtstart.ical:date.time:inSeconds ?SECS_PER_DAY).math:integerQuotient
) math:difference ?DELTA.
?DELTA math:notLessThan 0.
?DELTA math:notGreaterThan ?DUR.
}
=> { ?D k:temporalBoundsIntersect ?E }.
<> dc:description """
$Log: eventsOnDay.n3,v $
Revision 1.2 2003/07/08 22:59:10 connolly
pruned some junk.
starting to work on more cases
""".