event_nlp 0.6.4 → 0.6.5

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
  SHA256:
3
- metadata.gz: 006b95206123489efd7a4af7281c94cf04f9c87e2767b66f64ac8dfabf997935
4
- data.tar.gz: c24fa71f8468feea1740737afa65c1f37b338601a2bb483705f55ea636b7a6da
3
+ metadata.gz: 7b1e6f2d72c19b4eb44412c8ffdb4e9f4ec608e19007399c705b59d7d1c5a75b
4
+ data.tar.gz: '098c42a759bf88789275945a35da5c3e2a970b89f8a52d59c0d122c859c30e91'
5
5
  SHA512:
6
- metadata.gz: c27fc480731c2eb471bc80933f460a18c62ae6512b82336cd455c0733d267704959de4c0e37ee7a59d1918d8fd5971a3966bf15dd87886feff9dd48aacfaf472
7
- data.tar.gz: ab4d7de64261e1dfd3afd0ea29c4d84184ed8be70d6120340ba4959738838bbbd73126a8de992eb99809887ffe355c089628b426066a5603ddaa3ef1d886303b
6
+ metadata.gz: 1445fe116865cfe527862e13d0cb0f71c8bf3be774f81382db98c276df3d3ea98a94c97c998eb443544a0b1e2824cc15f37b1f3be7fa2c850f75f94c0df3fb8d
7
+ data.tar.gz: f9d55ee54ecedeba724748722fb96b64782f6bd685c16b9f0e9c65330a4551c2dcf54fb30185a30308eb8f930b3c92a5eb40e30ed5a6beacaf34457afdf51e19
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/event_nlp.rb CHANGED
@@ -63,6 +63,8 @@ class EventNlp
63
63
  if @debug then
64
64
  puts 'r.date: ' + r.date.inspect
65
65
  puts 'r.input: ' + r.input.inspect
66
+ puts 'EventNlp.new(r.date+1).parse(r.input).date: ' + \
67
+ EventNlp.new(r.date+1).parse(r.input).date.inspect
66
68
  end
67
69
 
68
70
  return [r.date] if (r.date == EventNlp.new(r.date+1).parse(r.input).date)
@@ -72,6 +74,8 @@ class EventNlp
72
74
  dates << r.date
73
75
  @now = if r.recurring == 'month' then
74
76
  (r.date.to_datetime >> 1).to_time
77
+ #elsif r.recurring == 'weekly'
78
+
75
79
  else
76
80
  r.date + 1
77
81
  end
@@ -142,7 +146,7 @@ class EventNlp
142
146
 
143
147
 
144
148
  puts 'day: ' + day.inspect if @debug
145
- raw_d = Chronic.parse(day + ' ' + Date::MONTHNAMES[@now.month])
149
+ raw_d = Chronic.parse(day + ' ' + Date::MONTHNAMES[@now.month], now: @now)
146
150
 
147
151
  # if the date is less than now then increment it by a month
148
152
  d = raw_d < @now ? (raw_d.to_date >> 1).to_time : raw_d
@@ -162,7 +166,7 @@ class EventNlp
162
166
  |title, recurring, time, raw_date, end_date|
163
167
 
164
168
  input = params[:input].clone
165
- d = Chronic.parse(raw_date + ' ' + time.to_s)
169
+ d = Chronic.parse(raw_date + ' ' + time.to_s, now: @now)
166
170
 
167
171
  if @debug then
168
172
  puts 'e300'
@@ -207,7 +211,7 @@ class EventNlp
207
211
  |title, recurring, time, raw_date, end_date|
208
212
 
209
213
  input = params[:input].clone
210
- d = Chronic.parse(raw_date)
214
+ d = Chronic.parse(raw_date, now: @now)
211
215
 
212
216
  if recurring =~ /day|week|month/ then
213
217
 
@@ -277,7 +281,7 @@ class EventNlp
277
281
 
278
282
  if recurring =~ /-/ then
279
283
  end_date = Chronic.parse d.to_date.to_s + ' ' +
280
- recurring[/(?<=-)\d+(?::\d+)?(?:[ap]m)?/]
284
+ recurring[/(?<=-)\d+(?::\d+)?(?:[ap]m)?/], now: @now
281
285
  end
282
286
 
283
287
  puts ['0.5'.highlight, title, recurring, d].join("\n").debug if @debug
@@ -301,7 +305,7 @@ class EventNlp
301
305
  get /^(\d(?:st|nd|rd|th) \w+) *(.*)\s+at\s+(\w+)/i do \
302
306
  |raw_day, title, time|
303
307
 
304
- d = Chronic.parse(raw_day + ' ' + time)
308
+ d = Chronic.parse(raw_day + ' ' + time, now: @now)
305
309
 
306
310
  puts ['1.5'.highlight, title, raw_day, time].inspect.debug if @debug
307
311
  { title: title, date: d }
@@ -319,9 +323,9 @@ class EventNlp
319
323
  puts ('raw_date: ' + raw_date).debug if @debug
320
324
 
321
325
  d = if date2 then
322
- Chronic.parse(date2 + ' '+ time2.to_s)
326
+ Chronic.parse(date2 + ' '+ time2.to_s, now: @now)
323
327
  else
324
- Chronic.parse(raw_date + ' '+ time2)
328
+ Chronic.parse(raw_date + ' '+ time2, now: @now)
325
329
  end
326
330
 
327
331
  puts ['4'.highlight, title, raw_date, date2, time2].inspect.debug if @debug
@@ -342,9 +346,9 @@ class EventNlp
342
346
  input = params[:input].clone
343
347
 
344
348
  if actual_date then
345
- d = Chronic.parse actual_date
349
+ d = Chronic.parse actual_date, now: @now
346
350
  else
347
- d = Chronic.parse(raw_day)
351
+ d = Chronic.parse(raw_day, now: @now)
348
352
  input.sub!(/#{weekdays}\b/i,
349
353
  %Q(#{raw_day} (#{d.strftime("#{d.day.ordinal} %b %Y")})))
350
354
  end
@@ -353,7 +357,7 @@ class EventNlp
353
357
 
354
358
  puts ('d: ' + d.inspect).debug if @debug
355
359
 
356
- d1, d2 = [t1, t2].map {|t| Chronic.parse([d.to_date.to_s, t].join(' ')) }
360
+ d1, d2 = [t1, t2].map {|t| Chronic.parse([d.to_date.to_s, t].join(' '), now: @now) }
357
361
 
358
362
  puts ['4.65'.highlight, input, title, raw_day, d1, d2].inspect.debug if @debug
359
363
 
@@ -375,10 +379,9 @@ class EventNlp
375
379
 
376
380
  input = params[:input].clone
377
381
 
378
- d = Chronic.parse(raw_day + ' ' + time.to_s)
382
+ d = Chronic.parse(raw_day + ' ' + time.to_s, now: @now)
379
383
 
380
384
  if recurring.nil?
381
- d = Chronic.parse(raw_day + ' ' + time.to_s)
382
385
  input.sub!(/#{weekdays}/i,
383
386
  %Q(#{raw_day} (#{d.strftime("#{d.day.ordinal} %b %Y")})))
384
387
  end
@@ -397,7 +400,7 @@ class EventNlp
397
400
  |raw_date, title, raw_time|
398
401
 
399
402
  d = Chronic.parse(raw_date + ' ' +
400
- raw_time, :endian_precedence => :little)
403
+ raw_time, now: @now, :endian_precedence => :little)
401
404
  recurring = nil
402
405
 
403
406
  puts [3, title, raw_date].inspect.debug if @debug
@@ -409,8 +412,8 @@ class EventNlp
409
412
  |raw_day, title, start_time, end_time|
410
413
 
411
414
  venue = title[/^at +(.*)/,1]
412
- d = Chronic.parse(raw_day + ' ' + start_time)
413
- d2 = Chronic.parse(raw_day + ' ' + end_time)
415
+ d = Chronic.parse(raw_day + ' ' + start_time, now: @now)
416
+ d2 = Chronic.parse(raw_day + ' ' + end_time, now: @now)
414
417
 
415
418
  puts ['1.44.3', title, raw_day].inspect.debug if @debug
416
419
  { title: title, date: d, end_date: d2, venue: venue }
@@ -423,7 +426,7 @@ class EventNlp
423
426
 
424
427
  puts [raw_day, title, time].inspect if @debug
425
428
  venue = title[/^at +(.*)/,1]
426
- d = Chronic.parse(raw_day + ' ' + time)
429
+ d = Chronic.parse(raw_day + ' ' + time, now: @now)
427
430
 
428
431
  puts [1.44, title, raw_day].inspect.debug if @debug
429
432
  { title: title, date: d, venue: venue }
@@ -434,7 +437,7 @@ class EventNlp
434
437
  get /#{weekdays}\b\s+#{days}\s+#{months}\s+(?:at )?(.*)\s+at\s+(#{times})/i \
435
438
  do |wday, day, month, title, time|
436
439
 
437
- d = Chronic.parse([day, month, time].join(' '))
440
+ d = Chronic.parse([day, month, time].join(' '), now: @now)
438
441
 
439
442
  puts ['1.44.5', day, month, title].inspect.debug if @debug
440
443
  { title: title, date: d }
@@ -450,7 +453,7 @@ class EventNlp
450
453
  get /^(\d+\/\d+\/\d+)\s*(\d+(?:\:\d+)?[ap]m)?\s+([^\*]+)(\*)?/ \
451
454
  do |raw_date, time, title, annualar|
452
455
 
453
- d = Chronic.parse(raw_date + ' ' + time.to_s,
456
+ d = Chronic.parse(raw_date + ' ' + time.to_s, now: @now,
454
457
  :endian_precedence => :little)
455
458
  recurring = nil
456
459
 
@@ -476,8 +479,8 @@ class EventNlp
476
479
 
477
480
  t1, t2 = xtimes.split(/-/,2)
478
481
 
479
- d1 = Chronic.parse([month, day, t1].join(' '))
480
- d2 = Chronic.parse([month, day, t2].join(' '))
482
+ d1 = Chronic.parse([month, day, t1].join(' '), now: @now)
483
+ d2 = Chronic.parse([month, day, t2].join(' '), now: @now)
481
484
 
482
485
  puts [4.5, title, d1, d2].inspect.debug if @debug
483
486
 
@@ -492,8 +495,8 @@ class EventNlp
492
495
  puts [month, day, xtimes, title].inspect if @debug
493
496
  t1, t2 = xtimes.split(/-/,2)
494
497
 
495
- d1 = Chronic.parse([month, day, t1 + ':00'].join(' '))
496
- d2 = Chronic.parse([month, day, t2 + ':00'].join(' '))
498
+ d1 = Chronic.parse([month, day, t1 + ':00'].join(' '), now: @now)
499
+ d2 = Chronic.parse([month, day, t2 + ':00'].join(' '), now: @now)
497
500
 
498
501
  puts [4.55, title, d1, d2].inspect.debug if @debug
499
502
 
@@ -505,7 +508,7 @@ class EventNlp
505
508
  get /^(?:#{weekdays2}\b) #{days} #{months}(?: at)? #{times}(.*)/i do \
506
509
  |day, month, t1, title|
507
510
 
508
- d1 = Chronic.parse([month, day, t1].join(' '))
511
+ d1 = Chronic.parse([month, day, t1].join(' '), now: @now)
509
512
 
510
513
  puts [4.6, title, d1].inspect.debug if @debug
511
514
 
@@ -518,7 +521,7 @@ class EventNlp
518
521
  |title, day, month, t1|
519
522
 
520
523
 
521
- d1 = Chronic.parse([month, day, t1].join(' '))
524
+ d1 = Chronic.parse([month, day, t1].join(' '), now: @now)
522
525
 
523
526
  puts [4.7, title, d1].inspect.debug if @debug
524
527
 
@@ -529,7 +532,7 @@ class EventNlp
529
532
  #
530
533
  get /(.*)\s+at\s+(#{times})/i do |title, time|
531
534
 
532
- d = Chronic.parse(time)
535
+ d = Chronic.parse(time, now: @now)
533
536
 
534
537
  puts [1.45, title].inspect.debug if @debug
535
538
  { title: title, date: d }
@@ -568,7 +571,7 @@ class EventNlp
568
571
 
569
572
  raw_date = day + ' ' + month
570
573
 
571
- d = Chronic.parse(raw_date,
574
+ d = Chronic.parse(raw_date, now: @now,
572
575
  :endian_precedence => :little)
573
576
  recurring = nil
574
577
 
@@ -613,7 +616,7 @@ class EventNlp
613
616
  :endian_precedence => :little, now: @now)
614
617
 
615
618
  if time2 then
616
- end_date = Chronic.parse(raw_date + ' ' + time2.to_s,
619
+ end_date = Chronic.parse(raw_date + ' ' + time2.to_s, now: @now,
617
620
  :endian_precedence => :little)
618
621
  end
619
622
 
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.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file