event_nlp 0.6.2 → 0.6.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/lib/event_nlp.rb +34 -16
- data.tar.gz.sig +0 -0
- 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: ed04654bfc6e7e852dcce5fc00c55b1428f2bb7468f1bd1934895dab9239403c
|
4
|
+
data.tar.gz: 9df3b5db5d7f473766b27efe0c2da3e599b4061e98fb5eec851c6570600f14a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 958c73c2bd2eed4a4937c8f8a269d758a92cc632ab366c78f00ee23cb19d6923bf99587fb53c649983397866bd5d55f2d34c7cb5d5656ebf61ace1e1ade83d4b
|
7
|
+
data.tar.gz: 6445772034c43de1489b0d8749ce53608554784f56d8bf20a7c58bf0938a87591d0ec80e4515a4bb787217bfd334d4f7844d1f39c2eddfc90c0b403eed0edd1e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/event_nlp.rb
CHANGED
@@ -38,21 +38,7 @@ class EventNlp
|
|
38
38
|
|
39
39
|
def parse(raws)
|
40
40
|
|
41
|
-
|
42
|
-
#
|
43
|
-
# e.g. Cafe meeting Thursday every 2 weeks =>
|
44
|
-
# Cafe meeting every 2nd Thursday
|
45
|
-
#
|
46
|
-
weekdays2 = (Date::DAYNAMES + Date::ABBR_DAYNAMES).join('|').downcase
|
47
|
-
pattern = /(?<day>#{weekdays2}) every (?<n>\d) weeks/i
|
48
|
-
found = raws.match(pattern)
|
49
|
-
|
50
|
-
s = if found then
|
51
|
-
s2 = "every %s %s" % [found[:n].to_i.ordinal, found[:day]]
|
52
|
-
raws.sub(pattern, s2)
|
53
|
-
else
|
54
|
-
raws
|
55
|
-
end
|
41
|
+
s = filter_irregular(raws)
|
56
42
|
|
57
43
|
#-----------------------------------------------------------
|
58
44
|
|
@@ -88,6 +74,37 @@ class EventNlp
|
|
88
74
|
|
89
75
|
private
|
90
76
|
|
77
|
+
def filter_irregular(raws)
|
78
|
+
|
79
|
+
# catch irregular expressions and interpret them in advance
|
80
|
+
#
|
81
|
+
# e.g. Cafe meeting Thursday every 2 weeks =>
|
82
|
+
# Cafe meeting every 2nd Thursday
|
83
|
+
#
|
84
|
+
weekdays2 = (Date::DAYNAMES + Date::ABBR_DAYNAMES).join('|').downcase
|
85
|
+
pattern = /(?<day>#{weekdays2}) every (?<n>\d) weeks/i
|
86
|
+
found = raws.match(pattern)
|
87
|
+
|
88
|
+
if found then
|
89
|
+
s2 = "every %s %s" % [found[:n].to_i.ordinal, found[:day]]
|
90
|
+
s = raws.sub(pattern, s2)
|
91
|
+
end
|
92
|
+
|
93
|
+
# e.g. "Cafe meeting 14th Monthly" =>
|
94
|
+
# Cafe meeting on the 14th of every month
|
95
|
+
#
|
96
|
+
found = raws.match(/(?<title>.*)\s+(?<day>\w+)(?:st|nd|rd|th) monthly/i)
|
97
|
+
|
98
|
+
if found then
|
99
|
+
s = "%s on the %s of every month" % [found[:title],
|
100
|
+
found[:day].to_i.ordinal]
|
101
|
+
end
|
102
|
+
|
103
|
+
puts 'filter_irregular - s: ' + s.inspect if @debug
|
104
|
+
return s || raws
|
105
|
+
|
106
|
+
end
|
107
|
+
|
91
108
|
def expressions(params)
|
92
109
|
|
93
110
|
starting = /(?:\(?\s*starting (\d+\w{2} \w+\s*\w*)(?: until (.*))?\s*\))?/
|
@@ -108,7 +125,7 @@ class EventNlp
|
|
108
125
|
|
109
126
|
# e.g. electricity bill on the 28th of every month
|
110
127
|
|
111
|
-
get /(.*) on the (#{days}) of every (#{periods})/ do |title, day, recurring|
|
128
|
+
get /(.*) on the (#{days}) of every (#{periods})/i do |title, day, recurring|
|
112
129
|
|
113
130
|
|
114
131
|
raw_d = Chronic.parse(day)
|
@@ -125,6 +142,7 @@ class EventNlp
|
|
125
142
|
|
126
143
|
end
|
127
144
|
|
145
|
+
#
|
128
146
|
|
129
147
|
get /^(.*)\s+(every \d\w+ \w+#{times}\s*#{starting})/ do \
|
130
148
|
|title, recurring, time, raw_date, end_date|
|
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
|
+
version: 0.6.3
|
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-04-
|
38
|
+
date: 2022-04-02 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: chronic_cron
|
metadata.gz.sig
CHANGED
Binary file
|