event_nlp 0.2.0 → 0.2.1
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.tar.gz.sig +0 -0
- data/lib/event_nlp.rb +42 -12
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09eb07c8e3c86c47ee94c8f312aec6c40f5e210e'
|
4
|
+
data.tar.gz: 0ac1428ab93322c9d6780a9511c710d28daac91e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aed1b7df145bc991641835ca102b71c4ab528a0697a3bf806c0637cd19426345ba4b2ccda9837cdbf7ebf455c4482c24ac53fe9447f86e13f06a76dfbd02a2ae
|
7
|
+
data.tar.gz: 1384916d35e6915e86f692ba2b1c714c7a2acaeaf734e7d91dd621a37e39f29ba4396dc9a20b78af74db1f29351fd5e2060d7713182a996146ffcd93d4abcf8d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/event_nlp.rb
CHANGED
@@ -25,13 +25,14 @@ class EventNlp
|
|
25
25
|
|
26
26
|
attr_accessor :params
|
27
27
|
|
28
|
-
def initialize(now=Time.now, params: {})
|
28
|
+
def initialize(now=Time.now, params: {}, debug: false)
|
29
29
|
|
30
30
|
super()
|
31
31
|
|
32
32
|
@now = now
|
33
33
|
@params = params
|
34
|
-
expressions(@params)
|
34
|
+
expressions(@params)
|
35
|
+
@debug = debug
|
35
36
|
|
36
37
|
end
|
37
38
|
|
@@ -82,12 +83,41 @@ class EventNlp
|
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
85
|
-
|
86
|
+
puts [0, title, recurring, time, raw_date, end_date].inspect if @debug
|
86
87
|
{input: input, title: title, recurring: recurring, date: d,
|
87
88
|
end_date: end_date}
|
88
89
|
|
89
90
|
end
|
90
91
|
|
92
|
+
# e.g. some event 1st Monday of every month (starting 3rd Jul 2017)
|
93
|
+
|
94
|
+
get /^(.*)\s+(\d(?:st|nd|rd|th) \w+ of every \w+(?: at (\d+[ap]m) )?)\s*#{starting}/ do \
|
95
|
+
|title, recurring, time, raw_date, end_date|
|
96
|
+
|
97
|
+
input = params[:input]
|
98
|
+
|
99
|
+
d = Chronic.parse(raw_date)
|
100
|
+
|
101
|
+
if recurring =~ /day|week|month/ then
|
102
|
+
|
103
|
+
if d < @now then
|
104
|
+
|
105
|
+
new_date = CronFormat.new(ChronicCron.new(recurring)\
|
106
|
+
.to_expression, d).to_time
|
107
|
+
input.gsub!(raw_date, new_date\
|
108
|
+
.strftime("#{new_date.day.ordinal} %b %Y"))
|
109
|
+
d = new_date
|
110
|
+
else
|
111
|
+
d = ChronicCron.new(recurring, d.to_date.to_time).to_time
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
puts [0.3, title, recurring, time, raw_date, end_date].inspect if @debug
|
116
|
+
{input: input, title: title, recurring: recurring, date: d,
|
117
|
+
end_date: end_date}
|
118
|
+
|
119
|
+
end
|
120
|
+
|
91
121
|
get /^(.*)(every .*)/ do |title, recurring|
|
92
122
|
|
93
123
|
input = params[:input]
|
@@ -95,7 +125,7 @@ class EventNlp
|
|
95
125
|
|
96
126
|
d = CronFormat.new(exp).to_time
|
97
127
|
|
98
|
-
|
128
|
+
puts [0.5, title, recurring, d].inspect if @debug
|
99
129
|
{input: input, title: title, recurring: recurring, date: d }
|
100
130
|
|
101
131
|
end
|
@@ -105,7 +135,7 @@ class EventNlp
|
|
105
135
|
get /(.*)\s+(\w+ \w+day of (?:the|every) month at .*)/ do
|
106
136
|
|title, recurring|
|
107
137
|
|
108
|
-
|
138
|
+
puts [1, title, recurring].inspect if @debug
|
109
139
|
{ title: title, recurring: recurring }
|
110
140
|
|
111
141
|
end
|
@@ -115,7 +145,7 @@ class EventNlp
|
|
115
145
|
|
116
146
|
d = Chronic.parse(raw_day + ' ' + time)
|
117
147
|
|
118
|
-
|
148
|
+
puts [1.5, title, raw_day].inspect if @debug
|
119
149
|
{ title: title, date: d }
|
120
150
|
|
121
151
|
end
|
@@ -128,7 +158,7 @@ class EventNlp
|
|
128
158
|
raw_time, :endian_precedence => :little)
|
129
159
|
recurring = nil
|
130
160
|
|
131
|
-
|
161
|
+
puts [3, title, raw_date].inspect if @debug
|
132
162
|
{ title: title, date: d }
|
133
163
|
end
|
134
164
|
|
@@ -137,7 +167,7 @@ class EventNlp
|
|
137
167
|
|
138
168
|
d = Chronic.parse(raw_day + ' ' + time)
|
139
169
|
|
140
|
-
|
170
|
+
puts [1.44, title, raw_day].inspect if @debug
|
141
171
|
{ title: title, date: d }
|
142
172
|
|
143
173
|
end
|
@@ -148,7 +178,7 @@ class EventNlp
|
|
148
178
|
|
149
179
|
d = Chronic.parse(time)
|
150
180
|
|
151
|
-
|
181
|
+
puts [1.45, title].inspect if @debug
|
152
182
|
{ title: title, date: d }
|
153
183
|
|
154
184
|
end
|
@@ -173,7 +203,7 @@ class EventNlp
|
|
173
203
|
end
|
174
204
|
end
|
175
205
|
|
176
|
-
|
206
|
+
puts [2, title, raw_date].inspect if @debug
|
177
207
|
{ title: title, date: d, recurring: recurring }
|
178
208
|
end
|
179
209
|
|
@@ -192,13 +222,13 @@ class EventNlp
|
|
192
222
|
end
|
193
223
|
|
194
224
|
|
195
|
-
|
225
|
+
puts [3, title, raw_date].inspect if @debug
|
196
226
|
{ title: title, date: d, recurring: recurring }
|
197
227
|
end
|
198
228
|
|
199
229
|
# e.g. 04-Aug@12:34
|
200
230
|
get '*' do |s|
|
201
|
-
puts 's: ' + s.inspect
|
231
|
+
puts 's: ' + s.inspect if @debug
|
202
232
|
'pattern unrecognised'
|
203
233
|
end
|
204
234
|
|
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
/WtgKLMzCAKTHZ2OpN3OTs6j+vsUBIwCb/Ki17Z4YULtRaGg7I8nTjTrHIIJ0yNm
|
32
32
|
kbRihMTezaC+4A==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2017-06-
|
34
|
+
date: 2017-06-08 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: chronic_cron
|
metadata.gz.sig
CHANGED
Binary file
|