event_nlp 0.5.0 → 0.5.1
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.tar.gz.sig +0 -0
- data/lib/event_nlp.rb +63 -33
- metadata +11 -12
- 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: 6cfeae1554c39f4b0829c15b6878a4214b45353b614ba1321540285980d9d722
|
4
|
+
data.tar.gz: 43502f60e11fd431026da2c82b303818f1ae98e973ed29e7b7cc0e254ae3030b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d56b0824eabf0189b84a5284cf28470a36ed4ae255e79564ffcdb2d23b16e830458d82fccf97bc7fc80c0708f5535f7f3f969018f271a26f43112ba6027e0dc
|
7
|
+
data.tar.gz: 9b09a7ce76de7dc2fed5100e6cf16279901798b514e22303f239024a4e49e0a28dc22dc8972dd6adaa63180141caa5b8c67d46b2b0f324b862f6974c63ce2078
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/event_nlp.rb
CHANGED
@@ -22,6 +22,7 @@ end
|
|
22
22
|
class EventNlp
|
23
23
|
include AppRoutes
|
24
24
|
using Ordinals
|
25
|
+
using ColouredText
|
25
26
|
|
26
27
|
attr_accessor :params
|
27
28
|
|
@@ -77,7 +78,7 @@ class EventNlp
|
|
77
78
|
|
78
79
|
|
79
80
|
if @debug then
|
80
|
-
puts [0.1, title, recurring, d].inspect
|
81
|
+
puts [0.1, title, recurring, d].inspect.debug
|
81
82
|
end
|
82
83
|
|
83
84
|
{title: title, recurring: recurring, date: d}
|
@@ -105,7 +106,7 @@ class EventNlp
|
|
105
106
|
end
|
106
107
|
|
107
108
|
if @debug then
|
108
|
-
puts [0.2, input, title, recurring, time, raw_date, end_date].inspect
|
109
|
+
puts [0.2, input, title, recurring, time, raw_date, end_date].inspect.debug
|
109
110
|
end
|
110
111
|
|
111
112
|
{input: input, title: title, recurring: recurring, date: d,
|
@@ -135,7 +136,7 @@ class EventNlp
|
|
135
136
|
end
|
136
137
|
end
|
137
138
|
|
138
|
-
puts [0.3, title, recurring, time, raw_date, end_date].inspect if @debug
|
139
|
+
puts [0.3, title, recurring, time, raw_date, end_date].inspect.debug if @debug
|
139
140
|
{input: input, title: title, recurring: recurring, date: d, end_date:
|
140
141
|
end_date}
|
141
142
|
|
@@ -158,7 +159,7 @@ class EventNlp
|
|
158
159
|
start_date = Chronic.parse(raw_start_date, now: @now - 1,
|
159
160
|
:endian_precedence => :little)
|
160
161
|
|
161
|
-
puts 'start_date: ' + start_date.inspect if @debug
|
162
|
+
puts ('start_date: ' + start_date.inspect).debug if @debug
|
162
163
|
|
163
164
|
if @now > start_date then
|
164
165
|
exp = ChronicCron.new(recurring, start_date).to_expression
|
@@ -190,7 +191,7 @@ class EventNlp
|
|
190
191
|
recurring[/(?<=-)\d+(?::\d+)?(?:[ap]m)?/]
|
191
192
|
end
|
192
193
|
|
193
|
-
puts [0.5, title, recurring, d].inspect if @debug
|
194
|
+
puts [0.5, title, recurring, d].inspect.debug if @debug
|
194
195
|
{input: input, title: title.rstrip, recurring: recurring,
|
195
196
|
date: d, end_date: end_date }
|
196
197
|
|
@@ -201,7 +202,7 @@ class EventNlp
|
|
201
202
|
get /(.*)\s+(\w+ \w+day of (?:the|every) month at .*)/ do
|
202
203
|
|title, recurring|
|
203
204
|
|
204
|
-
puts [1, title, recurring].inspect if @debug
|
205
|
+
puts [1, title, recurring].inspect.debug if @debug
|
205
206
|
{ title: title, recurring: recurring }
|
206
207
|
|
207
208
|
end
|
@@ -213,7 +214,7 @@ class EventNlp
|
|
213
214
|
|
214
215
|
d = Chronic.parse(raw_day + ' ' + time)
|
215
216
|
|
216
|
-
puts [1.5, title, raw_day, time].inspect if @debug
|
217
|
+
puts [1.5, title, raw_day, time].inspect.debug if @debug
|
217
218
|
{ title: title, date: d }
|
218
219
|
|
219
220
|
end
|
@@ -224,9 +225,9 @@ class EventNlp
|
|
224
225
|
relative_day = '|today|tomorrow|tonight'
|
225
226
|
get /^(.*)\s+(#{weekdays2+relative_day})(?: \(([^\)]+)\)) (at \d{1,2}(?::\d{2})?(?:[ap]m)?)/i \
|
226
227
|
do |title, raw_date, date2, time2|
|
227
|
-
puts 'time2: ' + time2.inspect if @debug
|
228
|
-
puts 'date2: ' + date2 if @debug
|
229
|
-
puts 'raw_date: ' + raw_date if @debug
|
228
|
+
puts ('time2: ' + time2.inspect).debug if @debug
|
229
|
+
puts ('date2: ' + date2).debug if @debug
|
230
|
+
puts ('raw_date: ' + raw_date).debug if @debug
|
230
231
|
|
231
232
|
d = if date2 then
|
232
233
|
Chronic.parse(date2 + ' '+ time2.to_s)
|
@@ -234,7 +235,7 @@ class EventNlp
|
|
234
235
|
Chronic.parse(raw_date + ' '+ time2)
|
235
236
|
end
|
236
237
|
|
237
|
-
puts [4, title, raw_date, date2, time2].inspect if @debug
|
238
|
+
puts [4, title, raw_date, date2, time2].inspect.debug if @debug
|
238
239
|
{title: title, date: d }
|
239
240
|
|
240
241
|
end
|
@@ -243,9 +244,11 @@ class EventNlp
|
|
243
244
|
get /^(.*)\s+(#{times2})(?: on) +#{weekdays}(?: \(([^\)]+)\))?/i \
|
244
245
|
do |title, xtimes, raw_day, actual_date|
|
245
246
|
|
246
|
-
|
247
|
-
|
248
|
-
|
247
|
+
if @debug then
|
248
|
+
puts ('actual_date: ' + actual_date.inspect).debug
|
249
|
+
puts ('raw_day: ' + raw_day.inspect).debug
|
250
|
+
puts ('xtimes: ' + xtimes.inspect).debug
|
251
|
+
end
|
249
252
|
|
250
253
|
input = params[:input].clone
|
251
254
|
|
@@ -259,11 +262,11 @@ class EventNlp
|
|
259
262
|
|
260
263
|
t1, t2 = xtimes.split(/-/,2)
|
261
264
|
|
262
|
-
puts 'd: ' + d.inspect if @debug
|
265
|
+
puts ('d: ' + d.inspect).debug if @debug
|
263
266
|
|
264
267
|
d1, d2 = [t1, t2].map {|t| Chronic.parse([d.to_date.to_s, t].join(' ')) }
|
265
268
|
|
266
|
-
puts [4.65, input, title, raw_day, d1, d2].inspect if @debug
|
269
|
+
puts [4.65, input, title, raw_day, d1, d2].inspect.debug if @debug
|
267
270
|
|
268
271
|
{input: input, title: title, date: d1, end_date: d2 }
|
269
272
|
|
@@ -274,9 +277,11 @@ class EventNlp
|
|
274
277
|
get /^(.*)\s+#{weekdays}(?: \(([^\)]+)\))?(#{times})?/i \
|
275
278
|
do |title, raw_day, actual_date, time|
|
276
279
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
+
if @debug then
|
281
|
+
puts ('actual_date: ' + actual_date.inspect).debug
|
282
|
+
puts ('raw_day: ' + raw_day.inspect).debug
|
283
|
+
puts ('time: ' + time.inspect).debug
|
284
|
+
end
|
280
285
|
|
281
286
|
input = params[:input].clone
|
282
287
|
|
@@ -288,10 +293,9 @@ class EventNlp
|
|
288
293
|
%Q(#{raw_day} (#{d.strftime("#{d.day.ordinal} %b %Y")})))
|
289
294
|
end
|
290
295
|
|
291
|
-
puts 'd: ' + d.inspect if @debug
|
292
|
-
|
296
|
+
puts ('d: ' + d.inspect).debug if @debug
|
293
297
|
|
294
|
-
puts [1.7, input, title, raw_day].inspect if @debug
|
298
|
+
puts [1.7, input, title, raw_day].inspect.debug if @debug
|
295
299
|
|
296
300
|
{input: input, title: title, date: d }
|
297
301
|
|
@@ -306,18 +310,32 @@ class EventNlp
|
|
306
310
|
raw_time, :endian_precedence => :little)
|
307
311
|
recurring = nil
|
308
312
|
|
309
|
-
puts [3, title, raw_date].inspect if @debug
|
313
|
+
puts [3, title, raw_date].inspect.debug if @debug
|
310
314
|
{ title: title, date: d }
|
311
315
|
end
|
312
316
|
|
317
|
+
# friday hall 2 11am until 12am
|
318
|
+
get /^#{weekdays}\s+(.*)\s+#{times} until #{times}$/i do \
|
319
|
+
|raw_day, title, start_time, end_time|
|
320
|
+
|
321
|
+
venue = title[/^at +(.*)/,1]
|
322
|
+
d = Chronic.parse(raw_day + ' ' + start_time)
|
323
|
+
d2 = Chronic.parse(raw_day + ' ' + end_time)
|
324
|
+
|
325
|
+
puts ['1.44.3', title, raw_day].inspect.debug if @debug
|
326
|
+
{ title: title, date: d, end_date: d2, venue: venue }
|
327
|
+
|
328
|
+
end
|
329
|
+
|
313
330
|
# friday hall 2 11am
|
314
331
|
get /^#{weekdays}\s+(.*)\s+(\d+(?::\d{2})?[ap]m)$/i do \
|
315
332
|
|raw_day, title, time|
|
316
333
|
|
334
|
+
venue = title[/^at +(.*)/,1]
|
317
335
|
d = Chronic.parse(raw_day + ' ' + time)
|
318
336
|
|
319
|
-
puts [1.44, title, raw_day].inspect if @debug
|
320
|
-
{ title: title, date: d }
|
337
|
+
puts [1.44, title, raw_day].inspect.debug if @debug
|
338
|
+
{ title: title, date: d, venue: venue }
|
321
339
|
|
322
340
|
end
|
323
341
|
|
@@ -327,7 +345,7 @@ class EventNlp
|
|
327
345
|
|
328
346
|
d = Chronic.parse([day, month, time].join(' '))
|
329
347
|
|
330
|
-
puts ['1.44.5', day, month, title].inspect if @debug
|
348
|
+
puts ['1.44.5', day, month, title].inspect.debug if @debug
|
331
349
|
{ title: title, date: d }
|
332
350
|
|
333
351
|
end
|
@@ -354,7 +372,7 @@ class EventNlp
|
|
354
372
|
end
|
355
373
|
|
356
374
|
|
357
|
-
puts [3, title, raw_date, time].inspect if @debug
|
375
|
+
puts [3, title, raw_date, time].inspect.debug if @debug
|
358
376
|
{ title: title, date: d, recurring: recurring }
|
359
377
|
end
|
360
378
|
|
@@ -370,9 +388,21 @@ class EventNlp
|
|
370
388
|
d1 = Chronic.parse([month, day, t1].join(' '))
|
371
389
|
d2 = Chronic.parse([month, day, t2].join(' '))
|
372
390
|
|
373
|
-
puts [4.5, title, d1, d2].inspect if @debug
|
391
|
+
puts [4.5, title, d1, d2].inspect.debug if @debug
|
374
392
|
|
375
393
|
{ title: title, date: d1, end_date: d2 }
|
394
|
+
end
|
395
|
+
|
396
|
+
# e.g. Wednesday 30th Nov at 9:15 10 Woodhouse Lane
|
397
|
+
|
398
|
+
get /^(?:#{weekdays2}) #{days} #{months}(?: at)? #{times}(.*)/i do \
|
399
|
+
|day, month, t1, title|
|
400
|
+
|
401
|
+
d1 = Chronic.parse([month, day, t1].join(' '))
|
402
|
+
|
403
|
+
puts [4.6, title, d1].inspect.debug if @debug
|
404
|
+
|
405
|
+
{ title: title, date: d1 }
|
376
406
|
end
|
377
407
|
|
378
408
|
# Some event (10 Woodhouse Lane) 30th Nov at 9:15-
|
@@ -383,7 +413,7 @@ class EventNlp
|
|
383
413
|
|
384
414
|
d1 = Chronic.parse([month, day, t1].join(' '))
|
385
415
|
|
386
|
-
puts [4.7, title, d1].inspect if @debug
|
416
|
+
puts [4.7, title, d1].inspect.debug if @debug
|
387
417
|
|
388
418
|
{ title: title, date: d1 }
|
389
419
|
end
|
@@ -394,7 +424,7 @@ class EventNlp
|
|
394
424
|
|
395
425
|
d = Chronic.parse(time)
|
396
426
|
|
397
|
-
puts [1.45, title].inspect if @debug
|
427
|
+
puts [1.45, title].inspect.debug if @debug
|
398
428
|
{ title: title, date: d }
|
399
429
|
|
400
430
|
end
|
@@ -407,7 +437,7 @@ class EventNlp
|
|
407
437
|
td = @now.to_date
|
408
438
|
d = Date.civil(td.year, td.month, -1).to_time
|
409
439
|
|
410
|
-
puts [5, title].inspect if @debug
|
440
|
+
puts [5, title].inspect.debug if @debug
|
411
441
|
{ title: title, date: d }
|
412
442
|
|
413
443
|
end
|
@@ -419,7 +449,7 @@ class EventNlp
|
|
419
449
|
td = @now.to_date
|
420
450
|
d = Date.civil(td.year, td.month, -1).to_time
|
421
451
|
|
422
|
-
puts [5.1, title].inspect if @debug
|
452
|
+
puts [5.1, title].inspect.debug if @debug
|
423
453
|
{ title: title, date: d }
|
424
454
|
|
425
455
|
end
|
@@ -464,7 +494,7 @@ class EventNlp
|
|
464
494
|
end
|
465
495
|
end
|
466
496
|
|
467
|
-
puts [6, title, raw_date, time1].inspect if @debug
|
497
|
+
puts [6, title, raw_date, time1].inspect.debug if @debug
|
468
498
|
{ title: title, date: d, end_date: end_date, recurring: recurring }
|
469
499
|
end
|
470
500
|
|
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.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,28 +30,28 @@ cert_chain:
|
|
30
30
|
hfzP67fp+s/TI6Tk+IvaEWBcfX7AV2XjfhS+q3uCBvQRjmbbRg3JO4XdjAQI3q8d
|
31
31
|
+P4=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
33
|
+
date: 2019-03-09 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: chronic_cron
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "~>"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0.4'
|
42
39
|
- - ">="
|
43
40
|
- !ruby/object:Gem::Version
|
44
|
-
version: 0.
|
41
|
+
version: 0.5.0
|
42
|
+
- - "~>"
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0.5'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
|
-
- - "~>"
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '0.4'
|
52
49
|
- - ">="
|
53
50
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
51
|
+
version: 0.5.0
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: app-routes
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
|
102
|
-
rubygems_version: 2.7.6
|
101
|
+
rubygems_version: 3.0.1
|
103
102
|
signing_key:
|
104
103
|
specification_version: 4
|
105
104
|
summary: 'Parses a calendar event for date, time, and description e.g. hall 2 friday
|
metadata.gz.sig
CHANGED
Binary file
|