sportdb-parser 0.6.9 → 0.6.11
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
- data/CHANGELOG.md +1 -1
- data/config/rounds_en.txt +1 -0
- data/lib/sportdb/parser/lexer.rb +57 -7
- data/lib/sportdb/parser/parser.rb +381 -358
- data/lib/sportdb/parser/racc_tree.rb +5 -3
- data/lib/sportdb/parser/token-status.rb +81 -8
- data/lib/sportdb/parser/token.rb +16 -1
- data/lib/sportdb/parser/version.rb +1 -1
- metadata +1 -1
@@ -169,10 +169,12 @@ end
|
|
169
169
|
|
170
170
|
|
171
171
|
MatchLine = Struct.new( :ord, :date, :time, :wday,
|
172
|
-
:team1, :team2,
|
173
|
-
:
|
172
|
+
:team1, :team2,
|
173
|
+
:score, :score_note,
|
174
|
+
:status,
|
174
175
|
:geo,
|
175
|
-
:timezone
|
176
|
+
:timezone,
|
177
|
+
:note ) do ## change to geos - why? why not?
|
176
178
|
|
177
179
|
def pretty_print( printer )
|
178
180
|
printer.text( "<MatchLine " )
|
@@ -133,20 +133,93 @@ NOTE_RE = %r{
|
|
133
133
|
## [in Estadio Victoria]
|
134
134
|
## [in UD José Brindis]
|
135
135
|
## [in Colomos Alfredo "Pistache" Torres stadium]
|
136
|
+
##
|
137
|
+
## TODO/FIX
|
138
|
+
## remove in ?? - is same as @ Estadio Victoria and such - why? why not=
|
136
139
|
)
|
137
|
-
|
140
|
+
)
|
141
|
+
\]
|
142
|
+
}ix
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
SCORE_NOTE_RE = %r{
|
147
|
+
\[
|
148
|
+
(?<score_note>
|
149
|
+
(?: # plain aet e.g. [aet]
|
150
|
+
aet | a\.e\.t\. |
|
151
|
+
after [ ] extra [ ] time
|
152
|
+
)
|
153
|
+
|
|
154
|
+
(?: # plain penalties e.g. [3-2 pen]
|
155
|
+
\d{1,2}-\d{1,2}
|
156
|
+
[ ]* (?: p|pen )
|
157
|
+
)
|
158
|
+
|
|
159
|
+
(?: # plain aet with penalties e.g. [aet; 4-3 pen] or [aet, 4-3p]
|
160
|
+
aet [ ]* [,;]
|
161
|
+
[ ]*
|
162
|
+
\d{1,2}-\d{1,2}
|
163
|
+
[ ]* (?: p|pen )
|
164
|
+
)
|
165
|
+
|
|
138
166
|
(?:
|
139
167
|
## e.g. Spain wins on penalties
|
140
168
|
## 1860 München wins on penalties etc.
|
141
169
|
## must start with digit 1-9 or letter
|
142
170
|
## todo - add more special chars - why? why not?
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
171
|
+
##
|
172
|
+
(?:
|
173
|
+
aet [ ]* ## allow space here - why? why not
|
174
|
+
[,;][ ]
|
175
|
+
)?
|
176
|
+
|
177
|
+
(?:
|
178
|
+
(?: # opt 1 - no team listed/named - requires score
|
179
|
+
wins? [ ] ## note - allow win or wins
|
180
|
+
(?: ## score
|
181
|
+
\d{1,2}-\d{1,2}
|
182
|
+
[ ]
|
183
|
+
)
|
184
|
+
on [ ] (?: pens | penalties |
|
185
|
+
aggregate )
|
186
|
+
)
|
187
|
+
|
|
188
|
+
(?: # opt 2 - team required; score optional
|
189
|
+
(?: ## team required
|
190
|
+
[1-9\p{L}][0-9\p{L} .-]+?
|
191
|
+
[ ]
|
192
|
+
)
|
193
|
+
wins [ ]
|
194
|
+
(?: ## score optional
|
195
|
+
\d{1,2}-\d{1,2}
|
196
|
+
[ ]
|
197
|
+
)?
|
198
|
+
on [ ] (?: pens | penalties |
|
199
|
+
aggregate )
|
200
|
+
### [^\]]*? ## allow more? use non-greedy
|
201
|
+
)
|
202
|
+
))
|
203
|
+
|
|
204
|
+
(?: ## e.g. agg 3-2 etc.
|
205
|
+
agg [ ] \d{1,2}-\d{1,2}
|
206
|
+
)
|
207
|
+
|
|
208
|
+
(?: ## e.g. agg 4-4, Ajax win on away goals
|
209
|
+
(?: ## agg 4-4, optional for now - why? why not?
|
210
|
+
agg [ ] \d{1,2}-\d{1,2}
|
211
|
+
[ ]*[,;][ ]
|
212
|
+
)?
|
213
|
+
(?: ## team required
|
214
|
+
[1-9\p{L}][0-9\p{L} .-]+?
|
215
|
+
[ ]
|
216
|
+
)
|
217
|
+
wins? [ ]
|
218
|
+
on [ ] away [ ] goals
|
219
|
+
)
|
220
|
+
) # score_note ref
|
221
|
+
\]
|
222
|
+
}ix
|
150
223
|
|
151
224
|
|
152
225
|
end # class Lexer
|
data/lib/sportdb/parser/token.rb
CHANGED
@@ -133,8 +133,8 @@ ANY_RE = %r{
|
|
133
133
|
|
134
134
|
RE = Regexp.union(
|
135
135
|
STATUS_RE,
|
136
|
+
SCORE_NOTE_RE,
|
136
137
|
NOTE_RE,
|
137
|
-
TIMEZONE_RE,
|
138
138
|
DURATION_RE, # note - duration MUST match before date
|
139
139
|
DATE_RE, ## note - date must go before time (e.g. 12.12. vs 12.12)
|
140
140
|
TIME_RE,
|
@@ -148,6 +148,21 @@ RE = Regexp.union(
|
|
148
148
|
)
|
149
149
|
|
150
150
|
|
151
|
+
GEO_BASICS_RE = %r{
|
152
|
+
(?<spaces> [ ]{2,}) |
|
153
|
+
(?<space> [ ])
|
154
|
+
|
|
155
|
+
(?<sym> [,\[] )
|
156
|
+
}ix
|
157
|
+
|
158
|
+
|
159
|
+
GEO_RE = Regexp.union(
|
160
|
+
TIMEZONE_RE,
|
161
|
+
GEO_BASICS_RE,
|
162
|
+
TEXT_RE,
|
163
|
+
ANY_RE,
|
164
|
+
)
|
165
|
+
|
151
166
|
|
152
167
|
######################################################
|
153
168
|
## goal mode (switched to by PLAYER_WITH_MINUTE_RE)
|