event_nlp 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c93ee0375545f7575bb9964ef18ab00d85acd57
4
- data.tar.gz: 6fc42b1f54e3bdb3707ab249509ab2a6347e8347
3
+ metadata.gz: 0b9b45e77e53d8fb10a418d7a49797ca09779286
4
+ data.tar.gz: 64cc7e8b8aac9b1dad55cf0842b1b0058762bcc7
5
5
  SHA512:
6
- metadata.gz: 8b8eaa9f79b809aecf758bfec2e1ef87e5f5a41e81e29ce3c0d75a17828e20f53d408f8074a6ed047efa6eef74158b01b8d4cbcbf1ebf4e314d2ff71d78ed501
7
- data.tar.gz: 7bc79074a73a76bc21bddb55ebe65cb1756451bb95c873cc56ae8ec210ce29e40264232d7b11b69f313dab210dde20ead75d8f8f05de45e7ec0c2d066dcdadac
6
+ metadata.gz: c25e6b6dd98e1dc4eba2255e21774cc4a91205e60decfac70d7232da1e4f39664b32d66fff8a687b82e61d3f301c97c42d70417e2cf2fde63f90c55393a060ef
7
+ data.tar.gz: 542f480ab1ff23cf5c3642cfeb30a876e621ab72fe9797cd8dea2eadd143966f0df77cd559797a1e71d3eefb47991e82d25feefd63e9d9a27d0f6e436038ccba
checksums.yaml.gz.sig CHANGED
@@ -1 +1 @@
1
- ��SK����"K��4�����a,<��_�a&�s�_{�њǘO^������ ���X2 �ٲBقߥ#�-3�����u8[/��;����YT��m{�>Q��>Ep2�]�G���m x�,1O!�������&n��HY{OWL�\�����1�ـd`�:�ֹ;�����>.}�X����i�����1��e8��tB]�փq�*sc��~Tc�/�Z��R��C���rZ��a��=NZ�����
1
+ c�Թ2'����ޅ��jpl���`�x��O[Do1�h�:�z;V���٘e]C}fU��S�u���R\Wf��D���r�ꨚ��t��ϰ����G"Z��⭝>�H�уfm[��T���̎�Ɠ�+/��2c�X��F��bOs<@�i��;TE�I4\$q�JT�ߡR}��S~HQ���X�F�u,);9OVL���~���c^�"�� ���tgdb-��_��Tnd�!�"���<�y��$r_��'wE�
data/lib/event_nlp.rb CHANGED
@@ -38,6 +38,7 @@ class EventNlp
38
38
 
39
39
  def parse(s)
40
40
 
41
+ @params[:input] = s
41
42
  r = run_route(s)
42
43
 
43
44
  return unless r.is_a? Hash
@@ -67,6 +68,7 @@ class EventNlp
67
68
  get /^(.*)\s+(every \d\w+ \w+#{time})\s*#{starting}/ do \
68
69
  |title, recurring, time, raw_date, end_date|
69
70
 
71
+ input = params[:input].clone
70
72
  d = Chronic.parse(raw_date + ' ' + time.to_s)
71
73
 
72
74
  if recurring =~ /day|week/ then
@@ -75,14 +77,19 @@ class EventNlp
75
77
 
76
78
  new_date = CronFormat.new(ChronicCron.new(recurring)\
77
79
  .to_expression, d).to_time
80
+ input.gsub!(raw_date, new_date\
81
+ .strftime("#{new_date.day.ordinal} %b %Y"))
78
82
  d = new_date
79
83
 
80
84
  end
81
85
  end
82
86
 
83
- puts [0, title, recurring, time, raw_date, end_date].inspect if @debug
84
- {title: title, recurring: recurring, date: d,
85
- end_date: end_date}
87
+ if @debug then
88
+ puts [0, input, title, recurring, time, raw_date, end_date].inspect
89
+ end
90
+
91
+ {input: input, title: title, recurring: recurring, date: d,
92
+ end_date: end_date}
86
93
 
87
94
  end
88
95
 
@@ -91,8 +98,7 @@ class EventNlp
91
98
  get /^(.*)\s+(\d(?:st|nd|rd|th) \w+ of every \w+(?: at (\d+[ap]m) )?)\s*#{starting}/ do \
92
99
  |title, recurring, time, raw_date, end_date|
93
100
 
94
- input = params[:input]
95
-
101
+ input = params[:input].clone
96
102
  d = Chronic.parse(raw_date)
97
103
 
98
104
  if recurring =~ /day|week|month/ then
@@ -110,20 +116,19 @@ class EventNlp
110
116
  end
111
117
 
112
118
  puts [0.3, title, recurring, time, raw_date, end_date].inspect if @debug
113
- {input: input, title: title, recurring: recurring, date: d,
114
- end_date: end_date}
119
+ {input: input, title: title, recurring: recurring, date: d, end_date:
120
+ end_date}
115
121
 
116
122
  end
117
123
 
118
124
  get /^(.*)(every .*)/ do |title, recurring|
119
125
 
120
- input = params[:input]
121
126
  exp = ChronicCron.new(recurring).to_expression
122
127
 
123
128
  d = CronFormat.new(exp).to_time
124
129
 
125
130
  puts [0.5, title, recurring, d].inspect if @debug
126
- {input: input, title: title, recurring: recurring, date: d }
131
+ {title: title, recurring: recurring, date: d }
127
132
 
128
133
  end
129
134
 
@@ -210,7 +215,8 @@ class EventNlp
210
215
  get /(\d[^\s]+)\s*(\d+(?:\:\d+)?[ap]m)?\s+([^\*]+)(\*)?/ do |raw_date,
211
216
  time, title, annualar|
212
217
 
213
- d = Chronic.parse(raw_date + ' ' + time.to_s, :endian_precedence => :little)
218
+ d = Chronic.parse(raw_date + ' ' + time.to_s,
219
+ :endian_precedence => :little)
214
220
  recurring = nil
215
221
 
216
222
  if annualar then
@@ -230,7 +236,8 @@ class EventNlp
230
236
  # some event Wednesday 11am
231
237
 
232
238
  relative_day = '|today|tomorrow|tonight'
233
- get /^(.*)\s+((?:#{weekday+relative_day})(?: \d{1,2}(?::\d{2})?[ap]m)?)/i do |title, raw_date|
239
+ get /^(.*)\s+((?:#{weekday+relative_day})(?: \d{1,2}(?::\d{2})?[ap]m)?)/i \
240
+ do |title, raw_date|
234
241
 
235
242
  d = Chronic.parse(raw_date)
236
243
 
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.2.6
4
+ version: 0.2.7
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-07-19 00:00:00.000000000 Z
34
+ date: 2017-09-17 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