event_nlp 0.5.2 → 0.5.3
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 +1 -2
- data/lib/event_nlp.rb +27 -8
- metadata +2 -2
- 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: 42e47f457a1e07759fc8b3de0ae3f85d35fc0679e252c9c52570457e5d389125
|
4
|
+
data.tar.gz: 58cabc06778bed4444a025092f47699089627145c06ab91befc1f02050e1a61a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e223d22b9a2404c8467fce4b9b8f58b9889dfffa15a3c83aaccc5c8d3912abaf50cf26bc46fbfc84744f345afa6905fbfcd7f27a49293d4b915c6cba72e49a47
|
7
|
+
data.tar.gz: b8f40f7a4168aaed947b00a2bbab9fd7864fc81388305cd8f6ede785bf84added0bef7fa3561f16400f35e2309eb0aefc0bdfab44ebef53df088058103eb3c19
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
��&� 1T2��-��D�A$�)y*|0eV�7k�4��
|
1
|
+
.��)�?�ª܋� �5� a���'�M
|
data/lib/event_nlp.rb
CHANGED
@@ -53,17 +53,19 @@ class EventNlp
|
|
53
53
|
def expressions(params)
|
54
54
|
|
55
55
|
starting = /(?:\(?\s*starting (\d+\w{2} \w+\s*\w*)(?: until (.*))?\s*\))?/
|
56
|
-
weekdays2 = Date::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
63
|
days = /(\d+(?:st|nd|rd|th))/
|
63
64
|
periods = /day|week|month/
|
64
65
|
|
65
66
|
#weekdays = Date::DAYNAMES.join('|').downcase
|
66
67
|
#
|
68
|
+
|
67
69
|
#times = /(?: *at )?\d[ap]m/
|
68
70
|
|
69
71
|
# e.g. electricity bill on the 28th of every month
|
@@ -223,7 +225,7 @@ class EventNlp
|
|
223
225
|
# some event Wednesday 11am
|
224
226
|
|
225
227
|
relative_day = '|today|tomorrow|tonight'
|
226
|
-
get /^(.*)\s+(#{weekdays2+relative_day})(?: \(([^\)]+)\)) (at \d{1,2}(?::\d{2})?(?:[ap]m)?)/i \
|
228
|
+
get /^(.*)\s+(#{weekdays2+relative_day}\b)(?: \(([^\)]+)\)) (at \d{1,2}(?::\d{2})?(?:[ap]m)?)/i \
|
227
229
|
do |title, raw_date, date2, time2|
|
228
230
|
puts ('time2: ' + time2.inspect).debug if @debug
|
229
231
|
puts ('date2: ' + date2).debug if @debug
|
@@ -241,7 +243,7 @@ class EventNlp
|
|
241
243
|
end
|
242
244
|
|
243
245
|
# Group meeting Red Hall 2pm-4pm on Monday (4th Dec 2017)
|
244
|
-
get /^(.*)\s+(#{times2})(?: on) +#{weekdays}(?: \(([^\)]+)\))?/i \
|
246
|
+
get /^(.*)\s+(#{times2})(?: on) +#{weekdays}\b(?: \(([^\)]+)\))?/i \
|
245
247
|
do |title, xtimes, raw_day, actual_date|
|
246
248
|
|
247
249
|
if @debug then
|
@@ -256,7 +258,7 @@ class EventNlp
|
|
256
258
|
d = Chronic.parse actual_date
|
257
259
|
else
|
258
260
|
d = Chronic.parse(raw_day)
|
259
|
-
input.sub!(/#{weekdays}/i,
|
261
|
+
input.sub!(/#{weekdays}\b/i,
|
260
262
|
%Q(#{raw_day} (#{d.strftime("#{d.day.ordinal} %b %Y")})))
|
261
263
|
end
|
262
264
|
|
@@ -274,7 +276,7 @@ class EventNlp
|
|
274
276
|
|
275
277
|
# hall 2 friday at 11am
|
276
278
|
|
277
|
-
get /^(.*)\s+#{weekdays}(?: \(([^\)]+)\))?(#{times})?/i \
|
279
|
+
get /^(.*)\s+#{weekdays}\b(?: \(([^\)]+)\))?(#{times})?/i \
|
278
280
|
do |title, raw_day, actual_date, time|
|
279
281
|
|
280
282
|
if @debug then
|
@@ -328,9 +330,10 @@ class EventNlp
|
|
328
330
|
end
|
329
331
|
|
330
332
|
# friday hall 2 11am
|
331
|
-
get /^#{weekdays}\s+(.*)\s+(\d+(?::\d{2})?[ap]m)$/i do \
|
333
|
+
get /^#{weekdays}\b\s+(.*)\s+(\d+(?::\d{2})?[ap]m)$/i do \
|
332
334
|
|raw_day, title, time|
|
333
335
|
|
336
|
+
puts [raw_day, title, time].inspect if @debug
|
334
337
|
venue = title[/^at +(.*)/,1]
|
335
338
|
d = Chronic.parse(raw_day + ' ' + time)
|
336
339
|
|
@@ -340,7 +343,7 @@ class EventNlp
|
|
340
343
|
end
|
341
344
|
|
342
345
|
# Tuesday 10th July hall 2 at 11am
|
343
|
-
get /#{weekdays}\s+#{days}\s+#{months}\s+(?:at )?(.*)\s+at\s+(#{times})/i \
|
346
|
+
get /#{weekdays}\b\s+#{days}\s+#{months}\s+(?:at )?(.*)\s+at\s+(#{times})/i \
|
344
347
|
do |wday, day, month, title, time|
|
345
348
|
|
346
349
|
d = Chronic.parse([day, month, time].join(' '))
|
@@ -392,10 +395,26 @@ class EventNlp
|
|
392
395
|
|
393
396
|
{ title: title, date: d1, end_date: d2 }
|
394
397
|
end
|
398
|
+
|
399
|
+
# Some event (10 Woodhouse Lane) 30th Nov from 9:15-17:00
|
400
|
+
|
401
|
+
get /^#{weekdays}\b #{months} #{days} #{times3} (.*)/i do \
|
402
|
+
|wday, month, day, xtimes, title|
|
403
|
+
|
404
|
+
puts [month, day, xtimes, title].inspect if @debug
|
405
|
+
t1, t2 = xtimes.split(/-/,2)
|
406
|
+
|
407
|
+
d1 = Chronic.parse([month, day, t1 + ':00'].join(' '))
|
408
|
+
d2 = Chronic.parse([month, day, t2 + ':00'].join(' '))
|
409
|
+
|
410
|
+
puts [4.55, title, d1, d2].inspect.debug if @debug
|
411
|
+
|
412
|
+
{ title: title, date: d1, end_date: d2 }
|
413
|
+
end
|
395
414
|
|
396
415
|
# e.g. Wednesday 30th Nov at 9:15 10 Woodhouse Lane
|
397
416
|
|
398
|
-
get /^(?:#{weekdays2}) #{days} #{months}(?: at)? #{times}(.*)/i do \
|
417
|
+
get /^(?:#{weekdays2}\b) #{days} #{months}(?: at)? #{times}(.*)/i do \
|
399
418
|
|day, month, t1, title|
|
400
419
|
|
401
420
|
d1 = Chronic.parse([month, day, t1].join(' '))
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
hfzP67fp+s/TI6Tk+IvaEWBcfX7AV2XjfhS+q3uCBvQRjmbbRg3JO4XdjAQI3q8d
|
31
31
|
+P4=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2019-03-
|
33
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: chronic_cron
|
metadata.gz.sig
CHANGED
Binary file
|