-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameReport.ebnf
688 lines (597 loc) · 15.6 KB
/
GameReport.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
(* Common Rules *)
pre = '<pre>' ;
pre_close = '</pre>' ;
tr = '<tr>' ;
tr_close = '</tr>' ;
td = '<td valign="top">' ;
td_close = '</td>' ;
p = '<p class="bnorm">' ;
p_norm = '<p class="norm">' ;
p_close = '</p>' ;
table = ?/<table[^>]*>/? ;
(*table = '<table width="100%%" cellspacing="20" border="0">' ; *)
table_close = '</table>' ;
anything_but_font_close = ?/.*(?=<\/font>)/? ;
font_size_2 = '<font size="2">' ;
font_white = '<font color="#000000">' ;
font_red = '<font color="#FF0000">' ;
font_close = '</font>' ;
(* J.Bradley Jr *)
short_name = ?/[A-Z]\.[A-Za-z\*\-\'\s]+/? ;
short_name_no_pos = ?/[A-Z]\.[A-Za-z\s\*\-\']+[A-Za-z](?= (1B|1|2B|2|3B|3|SS|S|LF|L|CF|C|RF|R|PR|DH|D|PH|P))/? ;
short_name_no_result = ?/[A-Z]\.[A-Za-z\s\*\-\']+(?= (WIN|W|LOSS|L|HOLD|H|SAVE|S|BS|B|[0-9]))/? ;
last_name = ?/[A-Za-z\-\'\s\*]+/? ;
last_name_no_in = ?/[A-Za-z\-\'\s\*]+(?= In)/? ;
full_name = ?/[A-Za-z\.\-\'\s\*]+/? ;
full_name_no_injured = ?/[A-Za-z\.\s\-\'\*]+(?= INJURED)/? ;
full_name_no_gem_event = ?/[A-Za-z\.\s\-\'\*]+(?= (robbed|blocked|turns))/? ;
full_name_no_of = ?/[A-Za-z\.\s\-\'\*]+(?= of)/? ;
nickname_no_sep = ?/[A-Za-z0-9\'\s]+(?=(\:|\.|\s+AB|\s+IP|\())/? ;
ws = ?/\s+/? ;
phrase = ?/[A-Za-z0-9\'\s\.\/]*/? ;
position = '1B' | '1' | '2B' | '2' | '3B' | '3' | 'SS' | 'S' | 'LF' | 'L' | 'CF' | 'C' | 'RF' | 'R' | 'PR' | 'DH' | 'D' | 'PH' | 'P';
parenthesized_position = '(' @:position ')';
year = ?/[0-9]{4}/? ;
mdy = ?/[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}/? ;
dash = '-' ;
decimal_number = ?/[0-9]?\.?[0-9]+/? ;
not_a_number = '----' ;
partial_inning_number = ?/([12]{1}\/3){0,1}/? ;
whole_number = ?/[0-9]+/? ;
whole_number_comma = ?/[0-9,]+/? ;
optionaless = ?/s?/? ;
whitespace = ?/\s+/? ;
weekday_long =
'Sunday' |
'Monday' |
'Tuesday' |
'Wednesday' |
'Thursday' |
'Friday' |
'Saturday'
;
month_long =
'January' |
'February' |
'March' |
'April' |
'May' |
'June' |
'July' |
'August' |
'September' |
'October' |
'November' |
'December'
;
duration =
hours:whole_number
':'
minutes:whole_number
;
day_night_time = 'Day' | 'Night' ;
weather = 'Good' | 'Average' | 'Bad' ;
long_date =
weekday:weekday_long
','
month:month_long
day:whole_ordinal
year:whole_number
;
whole_ordinal =
@:whole_number
('st' | 'nd' | 'rd' | 'th')
;
innings_pitched_number =
whole:whole_number
[part:partial_inning_number]
;
half_inning =
half:('Top' | 'Bot')
number:whole_ordinal
;
parenthesized_whole_ordinal = '(' @:whole_ordinal [')'] ;
(* Box Score Rules *)
boxscore_td_start = '<td valign="top">' ;
boxscore_p_start = '<p class="bnorm">' ;
boxscore_spacer =
>font_white
/\s*/
>font_close
;
(* <td valign="top"> <pre> <p class="bnorm"> *)
boxscore_header =
boxscore_td_start
pre
boxscore_p_start
;
boxscore_matchup =
['BOXSCORE:']
phrase:phrase
;
(* <font color="#FF0000"> 2015 Chicago Northsiders At 2015 Charlotte Monarchs 7/30/2015</font> *)
boxscore_matchup_header =
>font_red
@:boxscore_matchup
>font_close
;
boxscore_hitting_stat_label = 'AB' | 'R' | 'H' | 'RBI' | 'AVG' ;
(* <font color="#FF0000"> Northsiders AB R H RBI AVG Monarchs AB R H RBI AVG</font> *)
boxscore_hitting_header =
>font_red
phrase:phrase
>font_close
;
boxscore_hitting_sub_annotation = /[A-Z]?/ ;
boxscore_hitting_substitution =
@:boxscore_hitting_sub_annotation
'-'
;
(* PR,DH *)
boxscore_hitting_position = ','.{position} ;
(* T.La Stella 2B 3 0 1 1 .229 *)
boxscore_hitting_stat_line =
substitution:{boxscore_hitting_substitution}
player_name:short_name_no_pos
positions:boxscore_hitting_position
statistics:{(decimal_number | not_a_number)}
;
(* <font color="#000000">C-R.Tejada PR,SS 0 0 0 0 .000 D-J.Bradley Jr PR,DH 0 0 0 0 .238 </font> *)
boxscore_hitting_player_line =
>font_white
players:{boxscore_hitting_stat_line}
>font_close
;
(* Either '--' or '---' *)
dashes = ?/[\-]{2,3}/? ;
(* <font color="#000000"> -- -- -- --- -- -- -- --- </font> *)
boxscore_hitting_separator =
>font_white
/[\-\s]*/
>font_close
;
boxscore_hitting_total_line =
'Totals'
totals:{whole_number}
;
(* <font color="#FF0000"> Totals 42 8 16 8 Totals 41 6 15 6</font> *)
boxscore_hitting_totals =
>font_red
@:{boxscore_hitting_total_line}
>font_close
;
(* Player hitting stats and totals *)
boxscore_hitting =
header:boxscore_hitting_header
player_stats:{boxscore_hitting_player_line}
boxscore_hitting_separator
team_stats:boxscore_hitting_totals
;
(* <font color="#000000">C-Pinch Ran For Ramirez In 8th Inning</font> *)
boxscore_run_substitution =
>font_white
substitution:[boxscore_hitting_substitution]
'Pinch'
type:'Ran'
'For'
player:last_name_no_in
'In'
inning:whole_ordinal
'Inning'
>font_close
;
(* <font color="#000000">A-Pinch Hit For Cabrera In 6th Inning</font> *)
boxscore_hit_substitution =
>font_white
substitution:[boxscore_hitting_substitution]
'Pinch'
type:'Hit'
'For'
player:last_name_no_in
'In'
inning:whole_ordinal
'Inning'
>font_close
;
(* <font color="#000000">B-Subbed Defensively (SS) For Parra In 7th Inning</font> *)
boxscore_defensive_substitution =
>font_white
substitution:[boxscore_hitting_substitution]
'Subbed'
type:'Defensively'
position:parenthesized_position
'For'
player:last_name_no_in
'In'
inning:whole_ordinal
'Inning'
>font_close
;
(* <font color="#000000">G-Subbed (DH) For Dickerson In 10th Inning</font> *)
boxscore_dh_substitution =
>font_white
substitution:[boxscore_hitting_substitution]
'Subbed'
position:parenthesized_position
'For'
player:last_name_no_in
'In'
inning:whole_ordinal
'Inning'
>font_close
;
boxscore_substitution =
boxscore_run_substitution |
boxscore_hit_substitution |
boxscore_defensive_substitution |
boxscore_dh_substitution
;
boxscore_injury_duration =
'(for '
@:whole_number
'more'
('game)' | 'games)')
;
(* <font color="#000000">INJURY: Alexei Ramirez INJURED (for 1 more game) in 8th inning</font> *)
boxscore_injury =
>font_white
'INJURY:'
name:full_name_no_injured
'INJURED'
duration:boxscore_injury_duration
'in'
inning:whole_ordinal
'inning'
>font_close
;
boxscore_team_inning_runs = ?/[0-9]+/? ;
boxscore_team_totals =
runs:whole_number
hits:whole_number
errors:whole_number
;
(* <font color="#000000">Spiders......... 0 2 1 2 0 0 2 1 0 - 8 16 3</font> *)
boxscore_team =
>font_white
nickname:nickname_no_sep
?/\.*/?
runs:{boxscore_team_inning_runs}
'-'
totals:boxscore_team_totals
>font_close
;
boxscore_pitching_stat_label = 'IP' | 'H' | 'R' | 'ER' | 'BB' | 'SO' | 'HR' | 'PC' | 'ERA' | 'SCORESHEET' ;
record =
wins:whole_number
'-'
losses:whole_number
;
parenthesized_record = '(' @:record [')'] ;
(* <font color="#FF0000">Spiders (40-58) IP H R ER BB SO HR PC ERA SCORESHEET</font> *)
boxscore_pitching_header_team =
>font_red
nickname:nickname_no_sep
[record:parenthesized_record]
headers:{boxscore_pitching_stat_label}
>font_close
;
boxscore_pitching_result_win = @:'WIN' [parenthesized_record] ;
boxscore_pitching_result_win_abv = @:'W' parenthesized_record ;
boxscore_pitching_result_loss = @:'LOSS' [parenthesized_record] ;
boxscore_pitching_result_loss_abv = @:'L' parenthesized_record ;
boxscore_pitching_result_hold = @:'HOLD' parenthesized_whole_ordinal ;
boxscore_pitching_result_hold_abv = @:'H' parenthesized_whole_ordinal ;
boxscore_pitching_result_save = @:'SAVE' parenthesized_whole_ordinal ;
boxscore_pitching_result_save_abv = @:'S' parenthesized_whole_ordinal ;
boxscore_pitching_result_blown_save = @:'BS' parenthesized_whole_ordinal ;
boxscore_pitching_result_blown_save_abv = @:'B' parenthesized_whole_ordinal ;
boxscore_pitching_result_stat =
boxscore_pitching_result_loss |
boxscore_pitching_result_win |
boxscore_pitching_result_win_abv |
boxscore_pitching_result_loss_abv |
boxscore_pitching_result_hold |
boxscore_pitching_result_hold_abv |
boxscore_pitching_result_save |
boxscore_pitching_result_save_abv |
boxscore_pitching_result_blown_save |
boxscore_pitching_result_blown_save_abv
;
(* <font color="#000000">J.Lopez WIN(4-0) BS(1st) 1 1/3 1 0 0 1 0 0 24 2.96</font> *)
(* <font color="#000000">E.Santana WIN BS 8 1/3 5 3 3 3 6 2 113 A1 D6</font> *)
boxscore_pitching_stat_line =
>font_white
player_name:short_name_no_result
result_stats:{boxscore_pitching_result_stat}
ip:innings_pitched_number
statistics:{(decimal_number | not_a_number)}
[scoresheet:{scoresheet_index}]
>font_close
;
(* A1 D1 *)
scoresheet_index = ?/[A-Z]{1}[0-9]+/? ;
(* <font color="#FF0000">Totals 9 15 6 6 2 9 2</font> *)
boxscore_pitching_total_line =
>font_red
'Totals'
ip:innings_pitched_number
statistics:{decimal_number}
>font_close
;
boxscore_pitching_team =
header:boxscore_pitching_header_team
pitchers:{boxscore_pitching_stat_line}
totals:boxscore_pitching_total_line
;
boxscore_pitching =
away:boxscore_pitching_team
boxscore_spacer
home:boxscore_pitching_team
;
attendance_data = 'ATTENDANCE-' @:whole_number_comma ;
long_date_data = 'DATE-' @:long_date ;
time_data = 'TIME-' @:day_night_time ;
weather_data = 'WEATHER-' @:weather ;
duration_data = 'T-' @:duration ;
umpire_name = @:full_name [','] ;
(* <font color="#000000">UMPIRES- Phil Cuzzi, Jim Wolf, Ed Montague, Jerry Layne</font> *)
umpire_data =
>font_white
'UMPIRES-'
@:{umpire_name}
>font_close
;
peripheral_game_data =
>font_white
attendance:attendance_data
[date:long_date_data]
time:time_data
weather:weather_data
>font_close
[umpires:umpire_data]
>font_white
duration:duration_data
>font_close
;
boxscore_team_count_colon =
nickname:nickname_no_sep
':'
count:whole_number
;
boxscore_team_basic_rate =
nickname:nickname_no_sep
':'
count:whole_number
'for'
opportunities:whole_number
;
boxscore_team_statistic_details_name =
'LEFT ON BASE' |
'DOUBLE PLAYS' |
'TRIPLE PLAYS'
;
(* <font color="#000000">LEFT ON BASE- Toros: 7 Clydesdales: 4</font> *)
boxscore_team_statistic_details =
>font_white
name:boxscore_team_statistic_details_name
'-'
away:boxscore_team_count_colon
home:boxscore_team_count_colon
>font_close
;
boxscore_player_statistic_detail =
[>font_white]
name:short_name
['-']
[game_count:whole_number]
[season_count:parenthesized_whole_ordinal]
[',']
[>font_close]
;
boxscore_player_statistic_details_name =
'ERRORS' |
'DOUBLES' |
'TRIPLES' |
'HOME RUNS' |
'Homeruns' |
'SACRIFICE HITS' |
'SACRIFICE FLIES' |
'RBIs' |
'STOLEN BASES' |
'CAUGHT STEALING' |
'WALKS' |
'HIT BY PITCH' |
'STRIKE OUTS' |
'GIDP' |
'CATCHERS INTERFERENCE' |
'PASSED BALLS' |
'BALKS' |
'WILD PITCHES' |
'2-out RBI' |
'RLISP 2-out'
;
(*
* <font color="#000000">WALKS- J.Werth-2, M.Cabrera, C.Gomez, P.Alvarez, B.Moss, N.Markakis,</font>
* <font color="#000000"> D.Pedroia-2</font>
*)
boxscore_statistic_details =
>font_white
name:boxscore_player_statistic_details_name
'-'
data:{boxscore_player_statistic_detail}
[>font_close]
;
(* <font color="#000000">TEAM RISP- Stogies: 1 for 9 Knights: 3 for 7</font> *)
boxscore_risp_details =
>font_white
'TEAM RISP'
'-'
away:boxscore_team_basic_rate
home:boxscore_team_basic_rate
>font_close
;
gem_event = ?/[A-Za-z\s]+/? ;
gem_details =
gemmer:full_name_no_gem_event
action:('robbed' | 'blocked the plate' | 'turns')
[',']
[gemmee:full_name_no_of]
['of a']
['n']
event:gem_event
;
boxscore_web_gem =
[>font_white]
inning:half_inning
':'
gem_details:gem_details
('.' | '!')
[>font_close]
;
(*
* <font color="#000000">WEB GEMS- Bot 2nd: Jimmy Rollins robbed Yoenis Cespedes of a base hit.</font>
* <font color="#000000"> Bot 8th: Marcell Ozuna robbed Aramis Ramirez of an extra base hit.</font>
* <font color="#000000">WEB GEMS- Top 1st: Jonathan Lucroy blocked the plate, saving a run!</font>
*)
boxscore_web_gems =
>font_white
'WEB GEMS'
'-'
@:{boxscore_web_gem}
[>font_close]
;
boxscore =
matchup:boxscore_matchup_header
boxscore_spacer
hitting_boxscore:boxscore_hitting
boxscore_spacer
substitutions:{boxscore_substitution}
[boxscore_spacer] (* Omitted if no substitusions *)
injuries:{boxscore_injury}
[boxscore_spacer] (* Omitted if no injuries *)
team_boxscore:{boxscore_team}
boxscore_spacer
pitching_boxscore:{boxscore_pitching}
boxscore_spacer
peripheral_game_data:peripheral_game_data
team_statistics_details:{boxscore_team_statistic_details}
player_statistics_details:{boxscore_statistic_details}
[team_risp_details:boxscore_risp_details]
[web_gems:boxscore_web_gems]
;
boxscore_data =
td
pre
p
@:boxscore
p_close
pre_close
td_close
;
boxscore_row =
tr
@:{boxscore_data}
tr_close
;
page_break = "<p style='page-break-before:always' ></p>" ;
boxscore_table =
table
@:{boxscore_row}
table_close
;
boxscore_all =
page_break
@:{boxscore_table}
;
(* Game Stories *)
(* <font color="#FF0000">MIAMI AT ST. LOUIS</font> *)
game_story_header =
>font_red
phrase:phrase
>font_close
;
game_story_pitcher_decision =
type:('Win' | 'Loss')
':'
player:last_name
record:parenthesized_record
;
game_story_pitcher_save =
type:'Save'
':'
player:last_name
season_count:parenthesized_whole_ordinal
;
(* <font color="#000000">Win:Samardzija(4-1) Loss:Kuroda(2-1) Save:Giles(4th)</font> *)
game_story_pitcher_stats =
>font_white
winning_pitcher:game_story_pitcher_decision
losing_pitcher:game_story_pitcher_decision
[save_pitcher:game_story_pitcher_save]
>font_close
;
text_no_close_font = ?/[A-Za-z0-9'\s\(\)\!\?\.\,\/\-\;\*]*(?=<\/font>)/? ;
game_story_recap_line =
>font_white
@:text_no_close_font
>font_close
;
game_story_recap =
@:{game_story_recap_line}
;
game_story =
[boxscore_spacer]
matchup:game_story_header
away:boxscore_team
home:boxscore_team
pitcher_stats:game_story_pitcher_stats
[hitter_stats:boxscore_statistic_details]
boxscore_spacer
recap:game_story_recap
;
game_story_data =
td
pre
p_norm
@:{game_story}
p_close
pre_close
td_close
;
game_story_row =
tr
@:{game_story_data}
tr_close
;
game_story_table =
table
@:{game_story_row}
table_close
;
scoresheet_line =
>font_white
anything_but_font_close
>font_close
;
scoresheet_matchup_header =
>font_red
'SCORESHEET:'
boxscore_matchup
>font_close
;
scoresheet =
scoresheet_matchup_header
{scoresheet_line}
[>font_close]
;
full_recap =
pre
font_size_2
boxscores:{boxscore}
[game_stories:{game_story_recap}]
[font_close]
[scoresheet]
[{boxscore_spacer}]
[scoresheet]
pre_close
;