sportdb-parser 0.5.9 → 0.6.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.
@@ -7,13 +7,14 @@ class Lexer
7
7
  ##
8
8
  # keep 18h30 - why? why not?
9
9
  # add support for 6:30pm 8:20am etc. - why? why not?
10
-
10
+ #
11
+ # check - only support h e.g. 18h30 or 18H30 too - why? why not?
12
+ # e.g. 18.30 (or 18:30 or 18h30)
11
13
  TIME_RE = %r{
12
- ## e.g. 18.30 (or 18:30 or 18h30)
13
14
  (?<time> \b
14
- (?<hour>\d{1,2})
15
+ (?: (?<hour>\d{1,2})
15
16
  (?: :|\.|h )
16
- (?<minute>\d{2})
17
+ (?<minute>\d{2}))
17
18
  \b
18
19
  )
19
20
  }ix
@@ -42,9 +43,12 @@ TIME_RE = %r{
42
43
  # https://en.wikipedia.org/wiki/Time_zone
43
44
  # https://en.wikipedia.org/wiki/List_of_UTC_offsets
44
45
  # https://en.wikipedia.org/wiki/UTC−04:00 etc.
45
-
46
+ #
47
+ # e.g. (UTC-2) or (CEST/UTC-2) etc.
48
+ # todo check - only allow upcase
49
+ # or (utc-2) and (cest/utc-2) too - why? why not?
50
+
46
51
  TIMEZONE_RE = %r{
47
- ## e.g. (UTC-2) or (CEST/UTC-2) etc.
48
52
  (?<timezone>
49
53
  \(
50
54
  ## optional "local" timezone name eg. BRT or CEST etc.
@@ -60,6 +64,35 @@ TIMEZONE_RE = %r{
60
64
 
61
65
 
62
66
 
67
+ ## add wday / stand-alone week day - as separate regex or
68
+ ## use TEXT with is_wday? check or such with
69
+ ## requirement of beginning of line (anchored to line) only??
70
+ ## - why? why not?
71
+
72
+ WDAY_RE = %r{
73
+ (?<wday>
74
+ \b # note - alternation (|) is lowest precedence (such
75
+ # parathenes required around \b()\b !!!
76
+ ## note - NOT case sensitive!!!
77
+ (?<day_name>
78
+ (?-i:
79
+ Mon|Mo|
80
+ Tue|Tu|
81
+ Wed|We|
82
+ Thu|Th|
83
+ Fri|Fr|
84
+ Sat|Sa|
85
+ Sun|Su
86
+ ))
87
+ \b ## todo/check - must be followed by two spaces or space + [( etc.
88
+ ## to allow words starting with weekday abbrevations - why? why not?
89
+ ## check if any names (teams, rounds, etc) come up in practice
90
+ ## or maybe remove three letter abbrevations Mon/Tue
91
+ ## and keep only Mo/Tu/We etc. - why? why not?
92
+ )}x
93
+
94
+
95
+
63
96
 
64
97
  BASICS_RE = %r{
65
98
  ## e.g. (51) or (1) etc. - limit digits of number???
@@ -78,179 +111,18 @@ BASICS_RE = %r{
78
111
  (?<spaces> [ ]{2,}) |
79
112
  (?<space> [ ])
80
113
  |
81
- (?<sym>[;,@|\[\]-])
82
- }ix
83
-
84
-
85
- ## removed from basics
86
- =begin
87
- (?<none>
88
- (?<=[ \[]|^) # Positive lookbehind for space or [
89
- -
90
- (?=[ ]*;) # positive lookahead for space
91
- )
92
- |
93
- (?<vs>
94
- (?<=[ ]) # Positive lookbehind for space
95
- (?:
96
- vs\.?| ## allow optional dot (eg. vs. v.)
97
- v\.?|
98
- -
99
- ) # not bigger match first e.g. vs than v etc.
100
- (?=[ ]) # positive lookahead for space
101
- )
102
- |
103
-
104
- make - into a simple symbol !!!
105
- =end
106
-
107
-
108
- MINUTE_RE = %r{
109
- (?<minute>
110
- (?<=[ (]) # Positive lookbehind for space or opening ( e.g. (61') required
111
- (?<value>\d{1,3}) ## constrain numbers to 0 to 999!!!
112
- (?: \+
113
- (?<value2>\d{1,3})
114
- )?
115
- ' ## must have minute marker!!!!
116
- )
117
- }ix
118
-
119
-
120
- ## goal types
121
- # (pen.) or (pen) or (p.) or (p)
122
- ## (o.g.) or (og)
123
- GOAL_PEN_RE = %r{
124
- (?<pen> \(
125
- (?:pen|p)\.?
126
- \)
114
+ (?<sym> (?<=^|[ ]) ## positive lookahead
115
+ (?: ----|
116
+ ---|
117
+ --
118
+ )
119
+ (?=[ ]) ## positive lookahead
127
120
  )
128
- }ix
129
- GOAL_OG_RE = %r{
130
- (?<og> \(
131
- (?:og|o\.g\.)
132
- \)
133
- )
134
- }ix
135
-
136
-
137
-
138
-
139
-
140
-
141
- PROP_BASICS_RE = %r{
142
- (?<spaces> [ ]{2,}) |
143
- (?<space> [ ])
144
121
  |
145
- (?<sym>[.;,\(\)\[\]-]) ## note - dot (.) is the (all-important) end-of-prop marker!!!
122
+ (?<sym> [;,/@|\[\]-] )
146
123
  }ix
147
124
 
148
125
 
149
- ## name different from text (does not allow number in name/text)
150
- ##
151
- ## note - includes special handling for dot (.) if at the end of line!!!
152
- ## end-of-line dot (.) is the prop end-of-marker - do NOT eat-up!!!
153
-
154
- PROP_NAME_RE = %r{
155
- (?<prop_name> \b
156
- (?<name>
157
- \p{L}+
158
- (?: \. (?: (?![ ]*$) )
159
- )? ## edge case - check for end of prop marker! (e.g. Stop.)
160
- (?:
161
- [ ]? # only single spaces allowed inline!!!
162
- (?:
163
- (?:
164
- (?<=\p{L}) ## use lookbehind
165
- [/'-] ## must be surrounded by letters
166
- ## e.g. One/Two NOT
167
- ## One/ Two or One / Two or One /Two etc.
168
- (?=\p{L}) ## use lookahead
169
- )
170
- |
171
- (?:
172
- (?<=[ ]) ## use lookbehind -- add letter (plus dot) or such - why? why not?
173
- ['] ## must be surrounded by leading space and
174
- ## traling letters (e.g. UDI 'Beter Bed)
175
- (?=\p{L}) ## use lookahead
176
- )
177
- |
178
- (?:
179
- (?<=\p{L}) ## use lookbehind
180
- ['] ## must be surrounded by leading letter and
181
- ## trailing space PLUS letter (e.g. UDI' Beter Bed)
182
- (?=[ ]\p{L}) ## use lookahead (space WITH letter
183
- )
184
- |
185
- (?: \p{L}+
186
- (?: \.
187
- (?: (?![ ]*$) )
188
- )? ## last dot is delimiter!!!
189
- )
190
- )+
191
- )*
192
- )
193
- ## add lookahead - must be non-alphanum (or dot)
194
- (?=[ .,;\]\)]|$)
195
- )
196
- }ix
197
-
198
-
199
-
200
-
201
- ##############
202
- # add support for props/ attributes e.g.
203
- #
204
- # Germany: Neuer - Kimmich, Rüdiger, Tah [Y], Mittelstädt – Andrich [Y] (46' Groß),
205
- # Kroos (80' Can) – Musiala (74' Müller), Gündogan,
206
- # Wirtz (63' Sane) – Havertz (63' Füllkrug).
207
- # Scotland: Gunn – Porteous [R 44'], Hendry, Tierney (78' McKenna) – Ralston [Y],
208
- # McTominay, McGregor (67' Gilmour), Robertson – Christie (82' Shankland),
209
- # Adams (46' Hanley), McGinn (67' McLean).
210
- #
211
- ## note: colon (:) MUST be followed by one (or more) spaces
212
- ## make sure mon feb 12 18:10 will not match
213
- ## allow 1. FC Köln etc.
214
- ## Mainz 05:
215
- ## limit to 30 chars max
216
- ## only allow chars incl. intl but (NOT ()[]/;)
217
-
218
-
219
- PROP_KEY_RE = %r{
220
- (?<prop_key> \b
221
- (?<key>
222
- (?:\p{L}+
223
- |
224
- \d+ # check for num lookahead (MUST be space or dot)
225
- ## MUST be followed by (optional dot) and
226
- ## required space !!!
227
- ## MUST be follow by a to z!!!!
228
- \.? ## optional dot
229
- [ ]? ## make space optional too - why? why not?
230
- ## yes - eg. 1st, 2nd, 5th etc.
231
- \p{L}+
232
- )
233
- [\d\p{L}'/° -]*? ## allow almost anyting
234
- ## fix - add negative lookahead
235
- ## no space and dash etc.
236
- ## only allowed "inline" not at the end
237
- ## must end with latter or digit!
238
- )
239
- [ ]*? # slurp trailing spaces
240
- :
241
- (?=[ ]+) ## possitive lookahead (must be followed by space!!)
242
- )
243
- }ix
244
-
245
-
246
-
247
-
248
- PROP_RE = Regexp.union(
249
- PROP_BASICS_RE,
250
- MINUTE_RE,
251
- PROP_NAME_RE,
252
- )
253
-
254
126
 
255
127
 
256
128
  RE = Regexp.union( PROP_KEY_RE, ## start with prop key (match will/should switch into prop mode!!!)
@@ -259,8 +131,11 @@ RE = Regexp.union( PROP_KEY_RE, ## start with prop key (match will/should swit
259
131
  TIME_RE,
260
132
  DURATION_RE, # note - duration MUST match before date
261
133
  DATE_RE,
262
- SCORE_RE,
263
- BASICS_RE, MINUTE_RE,
134
+ WDAY_RE, # allow standalone weekday name (e.g. Mo/Tu/etc.) - why? why not?
135
+ SCORE_MORE_RE,
136
+ SCORE_RE, ## note basic score e.g. 1-1 must go after SCORE_MORE_RE!!!
137
+ BASICS_RE,
138
+ MINUTE_RE,
264
139
  GOAL_OG_RE, GOAL_PEN_RE,
265
140
  TEXT_RE )
266
141
 
@@ -3,8 +3,8 @@ module SportDb
3
3
  module Module
4
4
  module Parser
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 5
7
- PATCH = 9
6
+ MINOR = 6
7
+ PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -21,6 +21,8 @@ require_relative 'parser/token-score'
21
21
  require_relative 'parser/token-date'
22
22
  require_relative 'parser/token-text'
23
23
  require_relative 'parser/token-status'
24
+ require_relative 'parser/token-minute'
25
+ require_relative 'parser/token-prop' ## team prop(erty) mode (note - must be before token)
24
26
  require_relative 'parser/token'
25
27
  require_relative 'parser/lexer'
26
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-29 00:00:00.000000000 Z
11
+ date: 2025-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos
@@ -102,6 +102,8 @@ files:
102
102
  - lib/sportdb/parser/racc_parser.rb
103
103
  - lib/sportdb/parser/racc_tree.rb
104
104
  - lib/sportdb/parser/token-date.rb
105
+ - lib/sportdb/parser/token-minute.rb
106
+ - lib/sportdb/parser/token-prop.rb
105
107
  - lib/sportdb/parser/token-score.rb
106
108
  - lib/sportdb/parser/token-status.rb
107
109
  - lib/sportdb/parser/token-text.rb