event_nlp 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/event_nlp.rb +189 -173
- data.tar.gz.sig +0 -0
- metadata +35 -34
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23d131080f1c648f569969cdd3af18a8ee585978b832c0822d47604a14968236
|
4
|
+
data.tar.gz: 173cff064a42e901bfb055f29f08d4d1273c5b0d7509ce1af54bb708593b3b23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0c92ec588966b972c2fc2d0816ca066d4c06ea98230d8d1fb811a06a7811d283d3626fd36f5229af2b11ebd5ecf4dcf69ee092af538e872ce3aa9ab8f519b88
|
7
|
+
data.tar.gz: bbb4f4a06419da51042a791dbc9fdbabd77c874c911f4c46ba1463e67162474804ad4fa1fc25b7297d448d7cd2bc7a70bae3a7e604657285231cd213a9c4032e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/event_nlp.rb
CHANGED
@@ -12,7 +12,7 @@ module Ordinals
|
|
12
12
|
|
13
13
|
refine Integer do
|
14
14
|
def ordinal
|
15
|
-
self.to_s + ( (10...20).include?(self) ? 'th' :
|
15
|
+
self.to_s + ( (10...20).include?(self) ? 'th' :
|
16
16
|
%w{ th st nd rd th th th th th th }[self % 10] )
|
17
17
|
end
|
18
18
|
end
|
@@ -23,99 +23,114 @@ class EventNlp
|
|
23
23
|
include AppRoutes
|
24
24
|
using Ordinals
|
25
25
|
using ColouredText
|
26
|
-
|
26
|
+
|
27
27
|
attr_accessor :params
|
28
|
-
|
28
|
+
|
29
29
|
def initialize(now=Time.now, params: {}, debug: false)
|
30
|
-
|
30
|
+
|
31
31
|
super()
|
32
|
-
|
32
|
+
|
33
33
|
@now = now
|
34
34
|
@params = params
|
35
35
|
expressions(@params)
|
36
36
|
@debug = debug
|
37
37
|
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def parse(s)
|
41
41
|
|
42
42
|
@params[:input] = s
|
43
43
|
r = run_route(s)
|
44
44
|
|
45
45
|
return unless r.is_a? Hash
|
46
|
-
|
46
|
+
|
47
47
|
OpenStruct.new({input: s}.merge r)
|
48
|
-
|
49
|
-
end
|
48
|
+
|
49
|
+
end
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
def expressions(params)
|
53
|
+
def expressions(params)
|
54
54
|
|
55
55
|
starting = /(?:\(?\s*starting (\d+\w{2} \w+\s*\w*)(?: until (.*))?\s*\))?/
|
56
|
-
weekdays2 = (Date::DAYNAMES + Date::ABBR_DAYNAMES).join('|').downcase
|
56
|
+
weekdays2 = (Date::DAYNAMES + Date::ABBR_DAYNAMES).join('|').downcase
|
57
57
|
weekdays = "(%s)" % weekdays2
|
58
58
|
months = "(%s)" % (Date::MONTHNAMES[1..-1] + Date::ABBR_MONTHNAMES[1..-1])\
|
59
59
|
.join('|').downcase
|
60
60
|
times = /(?: *(?:at |@ |from )?(\d+(?::\d+)?(?:[ap]m|\b)) *)/
|
61
61
|
times2 = /\d+(?::\d+)?[ap]m-\d+(?::\d+)?[ap]m|\d+(?::\d+)?-\d+(?::\d+)?/
|
62
|
-
times3 = /(\d+(?::\d+)?[ap]m-\d+(?::\d+)?[ap]m|\d+(?::\d+)?-\d+(?::\d+)?)/
|
62
|
+
times3 = /(\d+(?::\d+)?[ap]m-\d+(?::\d+)?[ap]m|\d+(?::\d+)?-\d+(?::\d+)?)/
|
63
63
|
days = /(\d+(?:st|nd|rd|th))/
|
64
64
|
periods = /day|week|month/
|
65
|
-
|
65
|
+
|
66
66
|
#weekdays = Date::DAYNAMES.join('|').downcase
|
67
67
|
#
|
68
|
-
|
68
|
+
|
69
69
|
#times = /(?: *at )?\d[ap]m/
|
70
70
|
|
71
|
-
# e.g. electricity bill on the 28th of every month
|
71
|
+
# e.g. electricity bill on the 28th of every month
|
72
72
|
|
73
73
|
get /(.*) on the (#{days}) of every (#{periods})/ do |title, day, recurring|
|
74
74
|
|
75
75
|
|
76
76
|
raw_d = Chronic.parse(day)
|
77
|
-
|
77
|
+
|
78
78
|
# if the date is less than now then increment it by a month
|
79
79
|
d = raw_d < @now ? (raw_d.to_date >> 1).to_time : raw_d
|
80
|
-
|
81
|
-
|
80
|
+
|
81
|
+
|
82
82
|
if @debug then
|
83
83
|
puts [0.1, title, recurring, d].inspect.debug
|
84
84
|
end
|
85
|
-
|
86
|
-
{title: title, recurring: recurring, date: d}
|
87
|
-
|
85
|
+
|
86
|
+
{title: title, recurring: recurring, date: d}
|
87
|
+
|
88
88
|
end
|
89
|
-
|
90
89
|
|
91
|
-
|
90
|
+
|
91
|
+
get /^(.*)\s+(every \d\w+ \w+#{times}\s*#{starting})/ do \
|
92
92
|
|title, recurring, time, raw_date, end_date|
|
93
93
|
|
94
|
-
input = params[:input].clone
|
94
|
+
input = params[:input].clone
|
95
95
|
d = Chronic.parse(raw_date + ' ' + time.to_s)
|
96
|
-
|
96
|
+
|
97
|
+
if @debug then
|
98
|
+
puts 'e300'
|
99
|
+
puts 'd: ' + d.inspect
|
100
|
+
puts 'recurring: ' + recurring.inspect
|
101
|
+
end
|
102
|
+
|
97
103
|
if recurring =~ /day|week/ then
|
98
104
|
|
99
105
|
if d < @now then
|
100
106
|
|
101
|
-
|
102
|
-
|
107
|
+
cc = ChronicCron.new(recurring, d)
|
108
|
+
exp = cc.to_expression
|
109
|
+
puts 'exp: ' + exp.inspect if @debug
|
110
|
+
|
111
|
+
cf = CronFormat.new(exp, d)
|
112
|
+
cf.next until cf.to_time > @now
|
113
|
+
|
114
|
+
new_date = cf.to_time
|
115
|
+
puts 'new_date: ' + new_date.inspect if @debug
|
116
|
+
|
103
117
|
input.gsub!(raw_date, new_date\
|
104
|
-
.strftime("#{new_date.day.ordinal} %b %Y"))
|
118
|
+
.strftime("#{new_date.day.ordinal} %b %Y"))
|
105
119
|
d = new_date
|
106
|
-
|
120
|
+
|
107
121
|
end
|
108
122
|
end
|
109
|
-
|
123
|
+
|
110
124
|
if @debug then
|
111
|
-
puts
|
125
|
+
puts 'd: ' + d.inspect
|
126
|
+
puts ["0.2", input, title, recurring, time, raw_date, end_date].inspect.debug
|
112
127
|
end
|
113
|
-
|
114
|
-
{input: input, title: title, recurring: recurring, date: d,
|
115
|
-
end_date: end_date}
|
116
|
-
|
128
|
+
|
129
|
+
{input: input, title: title, recurring: recurring, date: d,
|
130
|
+
end_date: end_date}
|
131
|
+
|
117
132
|
end
|
118
|
-
|
133
|
+
|
119
134
|
# e.g. some event 1st Monday of every month (starting 3rd Jul 2017)
|
120
135
|
|
121
136
|
get /^(.*)\s+(\d(?:st|nd|rd|th) \w+ of every \w+(?: at (\d+[ap]m) )?)\s*#{starting}/ do \
|
@@ -123,55 +138,56 @@ class EventNlp
|
|
123
138
|
|
124
139
|
input = params[:input].clone
|
125
140
|
d = Chronic.parse(raw_date)
|
126
|
-
|
127
|
-
if recurring =~ /day|week|month/ then
|
128
|
-
|
141
|
+
|
142
|
+
if recurring =~ /day|week|month/ then
|
143
|
+
|
129
144
|
if d < @now then
|
130
145
|
|
131
146
|
new_date = CronFormat.new(ChronicCron.new(recurring)\
|
132
147
|
.to_expression, d).to_time
|
133
148
|
input.gsub!(raw_date, new_date\
|
134
|
-
.strftime("#{new_date.day.ordinal} %b %Y"))
|
149
|
+
.strftime("#{new_date.day.ordinal} %b %Y"))
|
135
150
|
d = new_date
|
136
151
|
else
|
137
152
|
d = ChronicCron.new(recurring, d.to_date.to_time).to_time
|
138
153
|
end
|
139
154
|
end
|
140
|
-
|
155
|
+
|
141
156
|
puts ['0.3'.highlight, title, recurring, time, raw_date, end_date].inspect.debug if @debug
|
142
|
-
{input: input, title: title, recurring: recurring, date: d, end_date:
|
157
|
+
{input: input, title: title, recurring: recurring, date: d, end_date:
|
143
158
|
end_date}
|
144
|
-
|
145
|
-
end
|
159
|
+
|
160
|
+
end
|
146
161
|
|
147
162
|
# some event every 2 weeks
|
148
163
|
# some event every 2 weeks at 6am starting from 14th Jan
|
149
164
|
# some event every 2 weeks at 6am starting from 18th Feb until 28th Oct
|
150
165
|
# some event every 2nd Monday (starting 7th Nov 2016)
|
151
|
-
# some event every 2nd Monday (starting 7th Nov until 3rd Dec)
|
166
|
+
# some event every 2nd Monday (starting 7th Nov until 3rd Dec)
|
152
167
|
# some event every 2 weeks (starting 02/11/17)
|
153
168
|
# some event every Wednesday 1pm-4pm
|
154
169
|
#
|
155
170
|
get /^(.*)(every .*)/ do |title, recurring|
|
156
171
|
|
157
172
|
input = params[:input].clone
|
173
|
+
puts 'recurring: ' + recurring.inspect if @debug
|
158
174
|
raw_start_date = recurring[/(?<=starting )[^\)]+/]
|
159
|
-
|
175
|
+
|
160
176
|
d = if raw_start_date then
|
161
|
-
start_date = Chronic.parse(raw_start_date, now: @now - 1,
|
177
|
+
start_date = Chronic.parse(raw_start_date, now: @now - 1,
|
162
178
|
:endian_precedence => :little)
|
163
179
|
|
164
180
|
puts ('recurring: ' + recurring.inspect).debug if @debug
|
165
181
|
puts ('start_date: ' + start_date.inspect).debug if @debug
|
166
|
-
|
182
|
+
|
167
183
|
if @now > start_date then
|
168
184
|
exp = ChronicCron.new(recurring, start_date, debug: @debug).to_expression
|
169
185
|
puts 'exp: ' + exp.inspect if @debug
|
170
|
-
|
186
|
+
|
171
187
|
cf = CronFormat.new(exp, start_date, debug: @debug)
|
172
188
|
puts ('cf.to_time: ' + cf.to_time.inspect).debug if @debug
|
173
189
|
cf.next until cf.to_time > start_date
|
174
|
-
|
190
|
+
|
175
191
|
new_date = cf.to_time
|
176
192
|
input.gsub!(/(?<=starting )[^\)]+/, new_date\
|
177
193
|
.strftime("#{new_date.day.ordinal} %b %Y"))
|
@@ -180,208 +196,208 @@ class EventNlp
|
|
180
196
|
else
|
181
197
|
start_date
|
182
198
|
end
|
183
|
-
|
199
|
+
|
184
200
|
else
|
185
201
|
exp = ChronicCron.new(recurring).to_expression
|
186
202
|
cf = CronFormat.new(exp, @now)
|
187
203
|
cf.to_time
|
188
204
|
end
|
189
|
-
|
190
205
|
|
191
|
-
|
206
|
+
|
207
|
+
|
192
208
|
if recurring =~ /-/ then
|
193
|
-
end_date = Chronic.parse d.to_date.to_s + ' ' +
|
194
|
-
recurring[/(?<=-)\d+(?::\d+)?(?:[ap]m)?/]
|
209
|
+
end_date = Chronic.parse d.to_date.to_s + ' ' +
|
210
|
+
recurring[/(?<=-)\d+(?::\d+)?(?:[ap]m)?/]
|
195
211
|
end
|
196
|
-
|
212
|
+
|
197
213
|
puts ['0.5'.highlight, title, recurring, d].join("\n").debug if @debug
|
198
|
-
{input: input, title: title.rstrip, recurring: recurring,
|
214
|
+
{input: input, title: title.rstrip, recurring: recurring,
|
199
215
|
date: d, end_date: end_date }
|
200
|
-
|
201
|
-
end
|
202
|
-
|
216
|
+
|
217
|
+
end
|
218
|
+
|
203
219
|
# some meeting 3rd thursday of the month at 7:30pm
|
204
220
|
# some meeting First thursday of the month at 7:30pm
|
205
|
-
get /(.*)\s+(\w+ \w+day of (?:the|every) month at .*)/ do
|
221
|
+
get /(.*)\s+(\w+ \w+day of (?:the|every) month at .*)/ do
|
206
222
|
|title, recurring|
|
207
223
|
|
208
224
|
puts ['1'.highlight, title, recurring].inspect.debug if @debug
|
209
225
|
{ title: title, recurring: recurring }
|
210
226
|
|
211
227
|
end
|
212
|
-
|
213
|
-
|
228
|
+
|
229
|
+
|
214
230
|
# 7th Oct Euston Station (meet at Timothy's house at 7pm)
|
215
231
|
get /^(\d(?:st|nd|rd|th) \w+) *(.*)\s+at\s+(\w+)/i do \
|
216
232
|
|raw_day, title, time|
|
217
|
-
|
233
|
+
|
218
234
|
d = Chronic.parse(raw_day + ' ' + time)
|
219
|
-
|
235
|
+
|
220
236
|
puts ['1.5'.highlight, title, raw_day, time].inspect.debug if @debug
|
221
237
|
{ title: title, date: d }
|
222
|
-
|
223
|
-
end
|
238
|
+
|
239
|
+
end
|
224
240
|
|
225
241
|
# some event Wednesday
|
226
242
|
# some event Wednesday 11am
|
227
|
-
|
243
|
+
|
228
244
|
relative_day = '|today|tomorrow|tonight'
|
229
245
|
get /^(.*)\s+(#{weekdays2+relative_day}\b)(?: \(([^\)]+)\)) (at \d{1,2}(?::\d{2})?(?:[ap]m)?)/i \
|
230
246
|
do |title, raw_date, date2, time2|
|
231
247
|
puts ('time2: ' + time2.inspect).debug if @debug
|
232
248
|
puts ('date2: ' + date2).debug if @debug
|
233
249
|
puts ('raw_date: ' + raw_date).debug if @debug
|
234
|
-
|
250
|
+
|
235
251
|
d = if date2 then
|
236
252
|
Chronic.parse(date2 + ' '+ time2.to_s)
|
237
253
|
else
|
238
254
|
Chronic.parse(raw_date + ' '+ time2)
|
239
255
|
end
|
240
|
-
|
256
|
+
|
241
257
|
puts ['4'.highlight, title, raw_date, date2, time2].inspect.debug if @debug
|
242
258
|
{title: title, date: d }
|
243
|
-
|
259
|
+
|
244
260
|
end
|
245
|
-
|
261
|
+
|
246
262
|
# Group meeting Red Hall 2pm-4pm on Monday (4th Dec 2017)
|
247
263
|
get /^(.*)\s+(#{times2})(?: on) +#{weekdays}\b(?: \(([^\)]+)\))?/i \
|
248
264
|
do |title, xtimes, raw_day, actual_date|
|
249
|
-
|
265
|
+
|
250
266
|
if @debug then
|
251
267
|
puts ('actual_date: ' + actual_date.inspect).debug
|
252
268
|
puts ('raw_day: ' + raw_day.inspect).debug
|
253
269
|
puts ('xtimes: ' + xtimes.inspect).debug
|
254
270
|
end
|
255
|
-
|
271
|
+
|
256
272
|
input = params[:input].clone
|
257
|
-
|
273
|
+
|
258
274
|
if actual_date then
|
259
275
|
d = Chronic.parse actual_date
|
260
276
|
else
|
261
|
-
d = Chronic.parse(raw_day)
|
277
|
+
d = Chronic.parse(raw_day)
|
262
278
|
input.sub!(/#{weekdays}\b/i,
|
263
|
-
%Q(#{raw_day} (#{d.strftime("#{d.day.ordinal} %b %Y")})))
|
279
|
+
%Q(#{raw_day} (#{d.strftime("#{d.day.ordinal} %b %Y")})))
|
264
280
|
end
|
265
281
|
|
266
282
|
t1, t2 = xtimes.split(/-/,2)
|
267
|
-
|
283
|
+
|
268
284
|
puts ('d: ' + d.inspect).debug if @debug
|
269
285
|
|
270
286
|
d1, d2 = [t1, t2].map {|t| Chronic.parse([d.to_date.to_s, t].join(' ')) }
|
271
|
-
|
287
|
+
|
272
288
|
puts ['4.65'.highlight, input, title, raw_day, d1, d2].inspect.debug if @debug
|
273
|
-
|
289
|
+
|
274
290
|
{input: input, title: title, date: d1, end_date: d2 }
|
275
|
-
|
276
|
-
end
|
277
|
-
|
291
|
+
|
292
|
+
end
|
293
|
+
|
278
294
|
# hall 2 friday at 11am
|
279
295
|
|
280
296
|
get /^(.*)\s+#{weekdays}\b(?: \(([^\)]+)\))?(#{times})?/i \
|
281
297
|
do |title, raw_day, actual_date, time|
|
282
|
-
|
298
|
+
|
283
299
|
if @debug then
|
284
300
|
puts ('actual_date: ' + actual_date.inspect).debug
|
285
301
|
puts ('raw_day: ' + raw_day.inspect).debug
|
286
302
|
puts ('time: ' + time.inspect).debug
|
287
303
|
end
|
288
|
-
|
304
|
+
|
289
305
|
input = params[:input].clone
|
290
|
-
|
306
|
+
|
291
307
|
if actual_date then
|
292
308
|
d = Chronic.parse(raw_day + ' ' + time.to_s)
|
293
309
|
else
|
294
|
-
d = Chronic.parse(raw_day + ' ' + time.to_s)
|
310
|
+
d = Chronic.parse(raw_day + ' ' + time.to_s)
|
295
311
|
input.sub!(/#{weekdays}/i,
|
296
|
-
%Q(#{raw_day} (#{d.strftime("#{d.day.ordinal} %b %Y")})))
|
312
|
+
%Q(#{raw_day} (#{d.strftime("#{d.day.ordinal} %b %Y")})))
|
297
313
|
end
|
298
|
-
|
314
|
+
|
299
315
|
puts ('d: ' + d.inspect).debug if @debug
|
300
|
-
|
316
|
+
|
301
317
|
puts [1.7, input, title, raw_day].inspect.debug if @debug
|
302
|
-
|
318
|
+
|
303
319
|
{input: input, title: title, date: d }
|
304
|
-
|
305
|
-
end
|
306
|
-
|
307
|
-
|
320
|
+
|
321
|
+
end
|
322
|
+
|
323
|
+
|
308
324
|
# e.g. 21/05/2017 Forum meetup at Roundpeg from 2pm
|
309
|
-
get /^(\d+\/\d+\/\d+)\s+(.*)(?: from|at)\s+(\d+[ap]m)/ do
|
325
|
+
get /^(\d+\/\d+\/\d+)\s+(.*)(?: from|at)\s+(\d+[ap]m)/ do
|
310
326
|
|raw_date, title, raw_time|
|
311
|
-
|
312
|
-
d = Chronic.parse(raw_date + ' ' +
|
327
|
+
|
328
|
+
d = Chronic.parse(raw_date + ' ' +
|
313
329
|
raw_time, :endian_precedence => :little)
|
314
|
-
recurring = nil
|
315
|
-
|
330
|
+
recurring = nil
|
331
|
+
|
316
332
|
puts [3, title, raw_date].inspect.debug if @debug
|
317
333
|
{ title: title, date: d }
|
318
|
-
end
|
319
|
-
|
334
|
+
end
|
335
|
+
|
320
336
|
# friday hall 2 11am until 12am
|
321
337
|
get /^#{weekdays}\s+(.*)\s+#{times} until #{times}$/i do \
|
322
338
|
|raw_day, title, start_time, end_time|
|
323
|
-
|
339
|
+
|
324
340
|
venue = title[/^at +(.*)/,1]
|
325
341
|
d = Chronic.parse(raw_day + ' ' + start_time)
|
326
342
|
d2 = Chronic.parse(raw_day + ' ' + end_time)
|
327
|
-
|
343
|
+
|
328
344
|
puts ['1.44.3', title, raw_day].inspect.debug if @debug
|
329
345
|
{ title: title, date: d, end_date: d2, venue: venue }
|
330
|
-
|
331
|
-
end
|
332
|
-
|
346
|
+
|
347
|
+
end
|
348
|
+
|
333
349
|
# friday hall 2 11am
|
334
350
|
get /^#{weekdays}\b\s+(.*)\s+(\d+(?::\d{2})?[ap]m)$/i do \
|
335
351
|
|raw_day, title, time|
|
336
|
-
|
352
|
+
|
337
353
|
puts [raw_day, title, time].inspect if @debug
|
338
354
|
venue = title[/^at +(.*)/,1]
|
339
355
|
d = Chronic.parse(raw_day + ' ' + time)
|
340
|
-
|
356
|
+
|
341
357
|
puts [1.44, title, raw_day].inspect.debug if @debug
|
342
358
|
{ title: title, date: d, venue: venue }
|
343
|
-
|
344
|
-
end
|
359
|
+
|
360
|
+
end
|
345
361
|
|
346
362
|
# Tuesday 10th July hall 2 at 11am
|
347
363
|
get /#{weekdays}\b\s+#{days}\s+#{months}\s+(?:at )?(.*)\s+at\s+(#{times})/i \
|
348
364
|
do |wday, day, month, title, time|
|
349
|
-
|
365
|
+
|
350
366
|
d = Chronic.parse([day, month, time].join(' '))
|
351
|
-
|
367
|
+
|
352
368
|
puts ['1.44.5', day, month, title].inspect.debug if @debug
|
353
369
|
{ title: title, date: d }
|
354
|
-
|
355
|
-
end
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
370
|
+
|
371
|
+
end
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
360
376
|
# 27-Mar@1436 some important day
|
361
377
|
# 25/07/2017 11pm some important day
|
362
378
|
#
|
363
379
|
get /^(\d+\/\d+\/\d+)\s*(\d+(?:\:\d+)?[ap]m)?\s+([^\*]+)(\*)?/ \
|
364
380
|
do |raw_date, time, title, annualar|
|
365
381
|
|
366
|
-
d = Chronic.parse(raw_date + ' ' + time.to_s,
|
382
|
+
d = Chronic.parse(raw_date + ' ' + time.to_s,
|
367
383
|
:endian_precedence => :little)
|
368
384
|
recurring = nil
|
369
|
-
|
385
|
+
|
370
386
|
if annualar then
|
371
|
-
|
387
|
+
|
372
388
|
recurring = 'yearly'
|
373
389
|
if d < @now then
|
374
|
-
d = Chronic.parse(raw_date, now: Time.local(@now.year + 1, 1, 1))
|
390
|
+
d = Chronic.parse(raw_date, now: Time.local(@now.year + 1, 1, 1))
|
375
391
|
end
|
376
392
|
end
|
377
|
-
|
378
|
-
|
393
|
+
|
394
|
+
|
379
395
|
puts [3, title, raw_date, time].inspect.debug if @debug
|
380
396
|
{ title: title, date: d, recurring: recurring }
|
381
397
|
end
|
382
398
|
|
383
399
|
|
384
|
-
|
400
|
+
|
385
401
|
# Some event (10 Woodhouse Lane) 30th Nov from 9:15-17:00
|
386
402
|
|
387
403
|
get /^(.*) #{days} #{months}(?: from)? (#{times2})/i do \
|
@@ -396,7 +412,7 @@ class EventNlp
|
|
396
412
|
|
397
413
|
{ title: title, date: d1, end_date: d2 }
|
398
414
|
end
|
399
|
-
|
415
|
+
|
400
416
|
# Some event (10 Woodhouse Lane) 30th Nov from 9:15-17:00
|
401
417
|
|
402
418
|
get /^#{weekdays}\b #{months} #{days} #{times3} (.*)/i do \
|
@@ -411,7 +427,7 @@ class EventNlp
|
|
411
427
|
puts [4.55, title, d1, d2].inspect.debug if @debug
|
412
428
|
|
413
429
|
{ title: title, date: d1, end_date: d2 }
|
414
|
-
end
|
430
|
+
end
|
415
431
|
|
416
432
|
# e.g. Wednesday 30th Nov at 9:15 10 Woodhouse Lane
|
417
433
|
|
@@ -423,8 +439,8 @@ class EventNlp
|
|
423
439
|
puts [4.6, title, d1].inspect.debug if @debug
|
424
440
|
|
425
441
|
{ title: title, date: d1 }
|
426
|
-
end
|
427
|
-
|
442
|
+
end
|
443
|
+
|
428
444
|
# Some event (10 Woodhouse Lane) 30th Nov at 9:15-
|
429
445
|
|
430
446
|
get /^(.*) #{days} #{months}(?: at)? (#{times})/i do \
|
@@ -441,73 +457,73 @@ class EventNlp
|
|
441
457
|
# hall 2 at 11am
|
442
458
|
#
|
443
459
|
get /(.*)\s+at\s+(#{times})/i do |title, time|
|
444
|
-
|
460
|
+
|
445
461
|
d = Chronic.parse(time)
|
446
|
-
|
462
|
+
|
447
463
|
puts [1.45, title].inspect.debug if @debug
|
448
464
|
{ title: title, date: d }
|
449
|
-
|
450
|
-
end
|
451
|
-
|
452
|
-
|
465
|
+
|
466
|
+
end
|
467
|
+
|
468
|
+
|
453
469
|
# Council Tax on the last day of the month
|
454
470
|
#
|
455
471
|
get /^(.*) (?:o[nf] the)\s*last day of the month/i do |title|
|
456
|
-
|
472
|
+
|
457
473
|
td = @now.to_date
|
458
474
|
d = Date.civil(td.year, td.month, -1).to_time
|
459
|
-
|
475
|
+
|
460
476
|
puts [5, title].inspect.debug if @debug
|
461
477
|
{ title: title, date: d }
|
462
|
-
|
463
|
-
end
|
464
|
-
|
478
|
+
|
479
|
+
end
|
480
|
+
|
465
481
|
# Council Tax last day of the month
|
466
482
|
#
|
467
483
|
get /^(.*) +last day of the month/i do |title|
|
468
|
-
|
484
|
+
|
469
485
|
td = @now.to_date
|
470
486
|
d = Date.civil(td.year, td.month, -1).to_time
|
471
|
-
|
487
|
+
|
472
488
|
puts [5.1, title].inspect.debug if @debug
|
473
489
|
{ title: title, date: d }
|
474
|
-
|
475
|
-
end
|
476
|
-
|
490
|
+
|
491
|
+
end
|
492
|
+
|
477
493
|
# some important day 11 Oct *
|
478
494
|
#
|
479
495
|
get /^(.*) +(\d+) +#{months} *(\*)?/i \
|
480
496
|
do |title, day, month, annualar|
|
481
|
-
|
497
|
+
|
482
498
|
raw_date = day + ' ' + month
|
483
499
|
|
484
|
-
d = Chronic.parse(raw_date,
|
500
|
+
d = Chronic.parse(raw_date,
|
485
501
|
:endian_precedence => :little)
|
486
502
|
recurring = nil
|
487
|
-
|
503
|
+
|
488
504
|
if annualar then
|
489
|
-
|
505
|
+
|
490
506
|
recurring = 'yearly'
|
491
507
|
if d < @now then
|
492
|
-
d = Chronic.parse(raw_date,
|
493
|
-
now: Time.local(@now.year + 1, 1, 1))
|
508
|
+
d = Chronic.parse(raw_date,
|
509
|
+
now: Time.local(@now.year + 1, 1, 1))
|
494
510
|
end
|
495
511
|
end
|
496
|
-
|
497
|
-
|
512
|
+
|
513
|
+
|
498
514
|
puts [6, title, raw_date].inspect.debug if @debug
|
499
515
|
{ title: title, date: d, recurring: recurring }
|
500
516
|
end
|
501
|
-
|
502
|
-
|
503
|
-
|
517
|
+
|
518
|
+
|
519
|
+
|
504
520
|
# Tuesday 3rd October gas service at Barbara's house morning 9am-1pm
|
505
521
|
#
|
506
522
|
get '*' do
|
507
|
-
|
523
|
+
|
508
524
|
s = params[:input]
|
509
|
-
|
510
|
-
time1, time2, month, weekday, day, end_date, annualar = nil, nil, nil,
|
525
|
+
|
526
|
+
time1, time2, month, weekday, day, end_date, annualar = nil, nil, nil,
|
511
527
|
nil, nil, nil, false
|
512
528
|
|
513
529
|
s2 = s.sub(/#{times}/i) {|x| time1 = x; ''}
|
@@ -522,29 +538,29 @@ class EventNlp
|
|
522
538
|
raw_date = [day, month].compact.join(' ')
|
523
539
|
raw_date = weekday if raw_date.empty?
|
524
540
|
|
525
|
-
d = Chronic.parse(raw_date + ' ' + time1.to_s,
|
541
|
+
d = Chronic.parse(raw_date + ' ' + time1.to_s,
|
526
542
|
:endian_precedence => :little, now: @now)
|
527
|
-
|
543
|
+
|
528
544
|
if time2 then
|
529
|
-
end_date = Chronic.parse(raw_date + ' ' + time2.to_s,
|
545
|
+
end_date = Chronic.parse(raw_date + ' ' + time2.to_s,
|
530
546
|
:endian_precedence => :little)
|
531
547
|
end
|
532
|
-
|
548
|
+
|
533
549
|
recurring = nil
|
534
|
-
|
550
|
+
|
535
551
|
if annualar then
|
536
|
-
|
552
|
+
|
537
553
|
recurring = 'yearly'
|
538
554
|
if d < @now then
|
539
|
-
d = Chronic.parse(raw_date, now: Time.local(@now.year + 1, 1, 1))
|
555
|
+
d = Chronic.parse(raw_date, now: Time.local(@now.year + 1, 1, 1))
|
540
556
|
end
|
541
|
-
end
|
542
|
-
|
557
|
+
end
|
558
|
+
|
543
559
|
puts [10, title, raw_date, time1].inspect.debug if @debug
|
544
560
|
{ title: title, date: d, end_date: end_date, recurring: recurring }
|
545
|
-
end
|
546
|
-
|
547
|
-
|
561
|
+
end
|
562
|
+
|
563
|
+
|
548
564
|
end
|
549
|
-
|
565
|
+
|
550
566
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_nlp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,52 +11,52 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjAyMTQwNDQxWhcN
|
15
|
+
MjMwMjAyMTQwNDQxWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDRlXO8
|
17
|
+
lKNDGq9FsP2ZGakZKcR2g8utQq4DCO4x2ZpGzdq2uRuvZl/TG1eUt4NrHi6CAoYZ
|
18
|
+
Q3Sf11JJCL4ZBEi6Qm4YVMQ06gdsWBeWcO9wnOv198eKqsWbVmzpvRWmKJvjpzEY
|
19
|
+
nilcadAm1CCadUvfOi25WNhz+4jbzP09rdrI64Rmp0GJv5DjmtmgznQEWWZPyRVw
|
20
|
+
5mbMIxAxepUus1KFkZSXsyqWsmcupJ0z4myicgD0GPNL47hO84DwG6KZ1dpVS/ar
|
21
|
+
E0KCPZPKIN7dnLsqgAnw41/VRQSDUdjyT7T8sv6Kb/wa6hXxaS/SFVlI8G5RI/la
|
22
|
+
tjGIHg84+JFySryZVGHpOepGxgILpeqNvXXIK59Az1/OiS70A3xQBFmHYUNngbJd
|
23
|
+
8Gk83TYzTksXvnVBEhJKZwZYuWHT32burAz7+RDBdXl2cdiwX5IjkUq0BqPaGeuu
|
24
|
+
ZpJl29gP1YlCImTGWEPx9y30G/kdNYuVOJbzk2UEdCSlYjAQVtrYLTGRW08CAwEA
|
25
|
+
AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUSXtv+Esp
|
26
|
+
k8epEo2XhtatYkQhLO0wJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
27
|
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEACwZ89nT9aFdxhWGboWw+R5rAnTRqDQS2U1/n7Vs0
|
29
|
+
uAMg5MVU/jIEFCnynXZMmJwzN3r972rkjxj9mn6DGnVu1YI1IAohMwls5BVPm4/V
|
30
|
+
HgOsV5YFOzfJpThCqVzo3HwkqZWoO7LEgIIHJ/3UYnCfWM6uHmDuyOTLnCHL+lVD
|
31
|
+
1pi26mG34ViOfEQzgW6HwswixuUQ4LI2eYtzyKIS3qAYEVm7UwujdbKghEycFKdF
|
32
|
+
sBJVdzARYZGMbrKm8dWeBWrMhW+Fdy8HlN0D4XMYmCIYghZ5XiOICaTlv4rYOkr8
|
33
|
+
sThE7E1FNUonatzkBVmSDlJZ6K0nBZLy3RKC48BP8SnSM/LtQe9atiiJBPOAOck3
|
34
|
+
yjnIKndZd6EKQ2X55kjrO1J+/2tqfMOUjH8/pJLmeeR8xV5+oAz65qpFx8FZOFPC
|
35
|
+
w8lJ+I6Lqqr5GpsweOnEHW4w200sMRD40u8qmGHrqirihL2KrwTD6A9UObvA5AxZ
|
36
|
+
4Z4EPvKg+3jsK9Gv3GGSLdrD
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-02-02 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: chronic_cron
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.5.0
|
47
44
|
- - "~>"
|
48
45
|
- !ruby/object:Gem::Version
|
49
|
-
version: '0.
|
46
|
+
version: '0.7'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.7.1
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 0.5.0
|
57
54
|
- - "~>"
|
58
55
|
- !ruby/object:Gem::Version
|
59
|
-
version: '0.
|
56
|
+
version: '0.7'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.7.1
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: app-routes
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,7 +78,7 @@ dependencies:
|
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: 0.1.19
|
80
80
|
description:
|
81
|
-
email:
|
81
|
+
email: digital.robertson@gmail.com
|
82
82
|
executables: []
|
83
83
|
extensions: []
|
84
84
|
extra_rdoc_files: []
|
@@ -103,7 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.7.10
|
107
108
|
signing_key:
|
108
109
|
specification_version: 4
|
109
110
|
summary: 'Parses a calendar event for date, time, and description e.g. hall 2 friday
|
metadata.gz.sig
CHANGED
Binary file
|