event_nlp 0.6.6 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/event_nlp.rb +57 -6
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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: 8cdc8db5361075d76541559dda4b9541afbef4af1f530fb1076d1a2e73b2bb2a
|
4
|
+
data.tar.gz: ab4558673af5119af70185d2b19f75d4d8757cd4afec2d0b5495935b4ce8d26b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a72a9209568969b91a85cb019440d8704ba34a6e5b3cf531353c60106f18fdbd4715d0beb5cd1f10023e1e379698631377287fca70471af25a5b9c2c7c7e3ce4
|
7
|
+
data.tar.gz: 5f581d752bd427cc347cde61e5776be7c47ac7f19440c2609d1721688af7d1f8aeebd8df0e5c8be88cdcf82a3f9b367680de2972ada5ea9e0bcb38a801e41734
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/event_nlp.rb
CHANGED
@@ -2,10 +2,18 @@
|
|
2
2
|
|
3
3
|
# file: event_nlp.rb
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
#require 'chronic_cron'
|
6
7
|
require 'ostruct'
|
7
|
-
require '
|
8
|
+
require 'requestor'
|
9
|
+
|
10
|
+
code = Requestor.read('http://a0.jamesrobertson.me.uk/rorb/r/ruby') do |x|
|
11
|
+
x.require 'app-routes'
|
12
|
+
x.require 'chronic_cron'
|
13
|
+
end
|
8
14
|
|
15
|
+
eval code
|
16
|
+
#require 'app-routes'
|
9
17
|
|
10
18
|
module Ordinals
|
11
19
|
|
@@ -53,7 +61,7 @@ class EventNlp
|
|
53
61
|
|
54
62
|
# returns an Array object of dates, projected from a recurring event
|
55
63
|
#
|
56
|
-
def project(s, year:
|
64
|
+
def project(s, year: @now.year)
|
57
65
|
|
58
66
|
r0 = parse s
|
59
67
|
r = parse r0.input
|
@@ -67,18 +75,19 @@ class EventNlp
|
|
67
75
|
EventNlp.new(r.date+1).parse(r.input).date.inspect
|
68
76
|
end
|
69
77
|
|
70
|
-
return [r.date] if (r.date == EventNlp.new(r.date+1).parse(r.input).date)
|
78
|
+
return [r.date] if (r.date == EventNlp.new(r.date+1, debug: @debug).parse(r.input).date)
|
71
79
|
|
72
80
|
while r.date.year == year.to_i do
|
73
81
|
|
74
82
|
dates << r.date
|
75
83
|
@now = if r.recurring == 'month' then
|
76
|
-
(r.date.
|
84
|
+
(r.date.to_date >> 1).to_time
|
77
85
|
#elsif r.recurring == 'weekly'
|
78
86
|
|
79
87
|
else
|
80
88
|
r.date + 1
|
81
89
|
end
|
90
|
+
puts '@now: ' + @now.inspect if @debug
|
82
91
|
#@now = r.date + 1
|
83
92
|
r = parse(r.input)
|
84
93
|
|
@@ -107,6 +116,18 @@ class EventNlp
|
|
107
116
|
s = raws.sub(pattern, s2)
|
108
117
|
end
|
109
118
|
|
119
|
+
months = (Date::MONTHNAMES + Date::ABBR_MONTHNAMES).join('|').downcase
|
120
|
+
|
121
|
+
# the following would be ambiguous input, but we will assume they
|
122
|
+
# meant the 14th day of every month
|
123
|
+
# e.g. "Cafe meeting 14th May Monthly"
|
124
|
+
found = raws.match(/(?<title>.*)\s+(?<day>\w+(?:st|nd|rd|th)) (#{months}) monthly/i)
|
125
|
+
|
126
|
+
if found then
|
127
|
+
s = "%s on the %s of every month" % [found[:title],
|
128
|
+
found[:day].to_i.ordinal]
|
129
|
+
end
|
130
|
+
|
110
131
|
# e.g. "Cafe meeting 14th Monthly" =>
|
111
132
|
# Cafe meeting on the 14th of every month
|
112
133
|
#
|
@@ -137,6 +158,8 @@ class EventNlp
|
|
137
158
|
weekdays = "(%s)" % weekdays2
|
138
159
|
months = "(%s)" % (Date::MONTHNAMES[1..-1] + Date::ABBR_MONTHNAMES[1..-1])\
|
139
160
|
.join('|').downcase
|
161
|
+
years = /(20[0-9]{2})/
|
162
|
+
|
140
163
|
times = /(?: *(?:at |@ |from )?(\d+(?::\d+)?(?:[ap]m|\b)) *)/
|
141
164
|
times2 = /\d+(?::\d+)?[ap]m-\d+(?::\d+)?[ap]m|\d+(?::\d+)?-\d+(?::\d+)?/
|
142
165
|
times3 = /(\d+(?::\d+)?[ap]m-\d+(?::\d+)?[ap]m|\d+(?::\d+)?-\d+(?::\d+)?)/
|
@@ -523,12 +546,40 @@ class EventNlp
|
|
523
546
|
{ title: title, date: d1 }
|
524
547
|
end
|
525
548
|
|
549
|
+
# Some event (10 Woodhouse Lane) 30th Nov at 9:15-10:00
|
550
|
+
|
551
|
+
get /^(.*) #{days} #{months} #{years}(?: at)? (#{times2})/i do \
|
552
|
+
|title, day, month, years, xtimes|
|
553
|
+
|
554
|
+
t1, t2 = xtimes.split(/-/,2)
|
555
|
+
puts '[title, years, day, month, t1] ' + [title, years, day, month, t1].inspect if @debug
|
556
|
+
d1 = Chronic.parse([month, day, years, t1].join(' '), now: @now)
|
557
|
+
d2 = Chronic.parse([month, day, years, t2].join(' '), now: @now)
|
558
|
+
|
559
|
+
puts [4.655, title, d1].inspect.debug if @debug
|
560
|
+
|
561
|
+
{ title: title.sub(/ on$/,''), date: d1, end_date: d2 }
|
562
|
+
end
|
563
|
+
|
564
|
+
# Some event (10 Woodhouse Lane) 30th Nov at 9:15
|
565
|
+
|
566
|
+
get /^(.*) #{days} #{months} #{years}(?: at)? (#{times})/i do \
|
567
|
+
|title, day, month, years, t1|
|
568
|
+
|
569
|
+
puts '[title, years, day, month, t1] ' + [title, years, day, month, t1].inspect if @debug
|
570
|
+
d1 = Chronic.parse([month, day, years, t1].join(' '), now: @now)
|
571
|
+
|
572
|
+
puts [4.66, title, d1].inspect.debug if @debug
|
573
|
+
|
574
|
+
{ title: title.sub(/ on$/,''), date: d1 }
|
575
|
+
end
|
576
|
+
|
526
577
|
# Some event (10 Woodhouse Lane) 30th Nov at 9:15-
|
527
578
|
|
528
579
|
get /^(.*) #{days} #{months}(?: at)? (#{times})/i do \
|
529
580
|
|title, day, month, t1|
|
530
581
|
|
531
|
-
|
582
|
+
puts '[title, day, month, t1] ' + [title, day, month, t1].inspect if @debug
|
532
583
|
d1 = Chronic.parse([month, day, t1].join(' '), now: @now)
|
533
584
|
|
534
585
|
puts [4.7, title, d1].inspect.debug if @debug
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
w8lJ+I6Lqqr5GpsweOnEHW4w200sMRD40u8qmGHrqirihL2KrwTD6A9UObvA5AxZ
|
36
36
|
4Z4EPvKg+3jsK9Gv3GGSLdrD
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2022-
|
38
|
+
date: 2022-08-10 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: chronic_cron
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
106
|
+
rubygems_version: 3.3.7
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: 'Parses a calendar event for date, time, and description e.g. hall 2 friday
|
metadata.gz.sig
CHANGED
Binary file
|