sportdb-parser 0.5.3 → 0.5.5
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/Manifest.txt +0 -1
- data/Rakefile +1 -2
- data/lib/sportdb/parser/parser.rb +111 -118
- data/lib/sportdb/parser/token-score.rb +5 -5
- data/lib/sportdb/parser/version.rb +1 -1
- data/lib/sportdb/parser.rb +0 -9
- metadata +2 -17
- data/lib/sportdb/parser/outline_reader.rb +0 -155
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c262398deab4e59ae7f57655a5ab67b03e4ad6290c66aa1b68f082448619c9c
|
4
|
+
data.tar.gz: 4c9b0c700f3bc472b27975cd1c4e7698eabf2e3965e0c1dbbed6feb4271103d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbfeb90c1e8499e67c653bc313696cdafd18c8f56af2b752aa6466e3ea76515d45ac91433741ba106b0ced8a55178aff54b348bf37463a86ec81127b87bec58d
|
7
|
+
data.tar.gz: f98cb825168e198601b43a70e8e19173ddbec39a93f04f4d277d632dc5d8f45577190e3f780b88fe48c9d6c194e7e59c1caf67897aebcdaa8c9a6527e1bbc2c1
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -9,107 +9,103 @@ class RaccMatchParser < Racc::Parser
|
|
9
9
|
##### State transition tables begin ###
|
10
10
|
|
11
11
|
racc_action_table = [
|
12
|
-
|
13
|
-
|
14
|
-
55, 61, 62, 65, 65, 31,
|
15
|
-
|
16
|
-
28, 25, 14, 15, 16,
|
17
|
-
25, 14, 15,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
102, 94, 60, 119, 28, 35, 37, 129, 43, 57,
|
13
|
+
38, 39, 22, 60, 43, 120, 41, 36, 49, 68,
|
14
|
+
55, 61, 62, 65, 65, 31, 128, 12, 40, 30,
|
15
|
+
58, 28, 61, 62, 66, 16, 12, 70, 30, 13,
|
16
|
+
28, 25, 14, 15, 16, 20, 22, 80, 13, 81,
|
17
|
+
25, 14, 15, 71, 20, 22, 54, 51, 54, 91,
|
18
|
+
72, 74, 75, 76, 44, 47, 46, 85, 86, 104,
|
19
|
+
105, 117, 118, 83, 52, 55, 52, 55, 125, 126,
|
20
|
+
134, 126, 87, 88, 65, 89, 49, 96, 98, 40,
|
21
|
+
99, 100, 43, 107, 43, 109, 35, 111, 112, 80,
|
22
|
+
65, 121, 122, 123, 49, 127, 65, 43, 43, 35,
|
23
|
+
132, 65, 49, 136, 137 ]
|
24
24
|
|
25
25
|
racc_action_check = [
|
26
|
-
63,
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
0, 1, 1, 1, 0, 1, 1,
|
31
|
-
0, 0, 0,
|
32
|
-
|
33
|
-
65, 81, 81,
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
26
|
+
63, 52, 25, 82, 16, 12, 13, 97, 27, 20,
|
27
|
+
14, 15, 20, 49, 16, 82, 16, 13, 18, 27,
|
28
|
+
52, 25, 25, 63, 25, 1, 97, 1, 15, 1,
|
29
|
+
24, 1, 49, 49, 26, 1, 0, 28, 0, 1,
|
30
|
+
0, 1, 1, 1, 0, 1, 1, 35, 0, 35,
|
31
|
+
0, 0, 0, 31, 0, 0, 19, 19, 48, 48,
|
32
|
+
33, 33, 33, 33, 17, 17, 17, 38, 38, 65,
|
33
|
+
65, 81, 81, 36, 19, 19, 48, 48, 92, 92,
|
34
|
+
124, 124, 41, 42, 43, 45, 51, 53, 55, 57,
|
35
|
+
59, 62, 67, 68, 70, 72, 73, 75, 76, 78,
|
36
|
+
80, 84, 87, 88, 91, 95, 102, 106, 108, 114,
|
37
|
+
115, 116, 126, 129, 131 ]
|
38
38
|
|
39
39
|
racc_action_pointer = [
|
40
40
|
34, 25, nil, nil, nil, nil, nil, nil, nil, nil,
|
41
|
-
nil, nil, -
|
42
|
-
|
43
|
-
nil,
|
44
|
-
nil, 71, 72, 56, nil, 68, nil, nil,
|
45
|
-
|
46
|
-
nil, nil,
|
47
|
-
|
48
|
-
|
49
|
-
nil,
|
50
|
-
|
51
|
-
nil, nil, nil, nil,
|
52
|
-
nil, nil, nil, nil, nil,
|
53
|
-
|
54
|
-
nil, nil ]
|
41
|
+
nil, nil, -2, 2, -5, 7, -2, 60, 2, 52,
|
42
|
+
-9, nil, nil, nil, 4, -4, 30, -8, 10, nil,
|
43
|
+
nil, 53, nil, 57, nil, 39, 57, nil, 49, nil,
|
44
|
+
nil, 71, 72, 56, nil, 68, nil, nil, 54, 7,
|
45
|
+
nil, 70, -3, 83, nil, 72, nil, 68, nil, 74,
|
46
|
+
nil, nil, 75, -5, nil, 40, nil, 76, 89, nil,
|
47
|
+
78, nil, 91, 89, nil, 93, 94, nil, 91, nil,
|
48
|
+
72, 59, -1, nil, 97, nil, nil, 98, 99, nil,
|
49
|
+
nil, 88, 74, nil, nil, 101, nil, 2, nil, nil,
|
50
|
+
nil, nil, 78, nil, nil, nil, 91, nil, 92, nil,
|
51
|
+
nil, nil, nil, nil, 102, 99, 83, nil, nil, nil,
|
52
|
+
nil, nil, nil, nil, 76, nil, 96, nil, nil, 97,
|
53
|
+
nil, 105, nil, nil, nil, nil, nil, nil ]
|
55
54
|
|
56
55
|
racc_action_default = [
|
57
56
|
-90, -90, -1, -3, -4, -5, -6, -7, -8, -9,
|
58
57
|
-10, -11, -90, -90, -41, -54, -90, -90, -90, -90,
|
59
|
-
-
|
58
|
+
-51, -53, -56, -65, -66, -90, -90, -74, -90, -79,
|
60
59
|
-89, -90, -2, -90, -13, -20, -90, -39, -90, -37,
|
61
|
-
-55, -90, -90, -90, -40, -90, -43, -44, -90, -
|
62
|
-
-
|
60
|
+
-55, -90, -90, -90, -40, -90, -43, -44, -90, -90,
|
61
|
+
-46, -90, -90, -90, -60, -90, -52, -54, -71, -90,
|
63
62
|
-68, -69, -90, -81, -82, -85, -73, -90, -77, -80,
|
64
|
-
-90,
|
63
|
+
-90, 138, -90, -90, -15, -16, -18, -21, -22, -24,
|
65
64
|
-90, -90, -90, -32, -90, -35, -36, -90, -90, -42,
|
66
|
-
-45, -90, -
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-67, -25 ]
|
65
|
+
-45, -90, -90, -49, -57, -90, -59, -61, -63, -67,
|
66
|
+
-70, -83, -90, -86, -87, -88, -76, -78, -75, -12,
|
67
|
+
-14, -17, -19, -23, -90, -90, -27, -29, -30, -31,
|
68
|
+
-33, -34, -38, -72, -90, -48, -90, -58, -62, -90,
|
69
|
+
-84, -90, -26, -28, -47, -50, -64, -25 ]
|
72
70
|
|
73
71
|
racc_goto_table = [
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
nil, nil, nil,
|
78
|
-
|
79
|
-
nil, nil, nil, nil, nil, nil,
|
80
|
-
nil, nil,
|
81
|
-
nil, nil, nil,
|
82
|
-
nil,
|
72
|
+
48, 34, 69, 101, 79, 92, 50, 106, 2, 32,
|
73
|
+
108, 1, 33, 73, 77, 78, 115, 116, 82, 84,
|
74
|
+
114, 45, 56, 95, 97, 42, 67, 103, nil, nil,
|
75
|
+
nil, nil, nil, 93, nil, 90, nil, nil, nil, nil,
|
76
|
+
nil, nil, 130, nil, nil, 124, nil, 113, nil, nil,
|
77
|
+
nil, nil, nil, nil, nil, nil, 133, nil, nil, nil,
|
78
|
+
nil, nil, 110, nil, nil, nil, nil, nil, nil, nil,
|
79
|
+
nil, nil, nil, 93, nil, nil, nil, nil, nil, nil,
|
80
|
+
nil, 69, nil, 69, nil, nil, nil, nil, nil, nil,
|
83
81
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
84
|
-
nil, nil, nil,
|
85
|
-
nil, nil, 139 ]
|
82
|
+
nil, nil, nil, 131, nil, nil, nil, nil, 135 ]
|
86
83
|
|
87
84
|
racc_goto_check = [
|
88
|
-
|
85
|
+
26, 13, 38, 18, 17, 28, 27, 36, 2, 2,
|
89
86
|
36, 1, 12, 14, 15, 16, 19, 20, 21, 22,
|
90
|
-
18, 24,
|
91
|
-
nil, nil, nil,
|
92
|
-
|
93
|
-
nil, nil, nil, nil, nil, nil,
|
87
|
+
18, 24, 29, 30, 31, 35, 37, 40, nil, nil,
|
88
|
+
nil, nil, nil, 26, nil, 27, nil, nil, nil, nil,
|
89
|
+
nil, nil, 18, nil, nil, 28, nil, 17, nil, nil,
|
90
|
+
nil, nil, nil, nil, nil, nil, 18, nil, nil, nil,
|
94
91
|
nil, nil, 13, nil, nil, nil, nil, nil, nil, nil,
|
95
|
-
nil, nil, nil,
|
96
|
-
nil,
|
92
|
+
nil, nil, nil, 26, nil, nil, nil, nil, nil, nil,
|
93
|
+
nil, 38, nil, 38, nil, nil, nil, nil, nil, nil,
|
97
94
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
98
|
-
nil, nil, nil,
|
99
|
-
nil, nil, 28 ]
|
95
|
+
nil, nil, nil, 13, nil, nil, nil, nil, 26 ]
|
100
96
|
|
101
97
|
racc_goto_pointer = [
|
102
98
|
nil, 11, 8, nil, nil, nil, nil, nil, nil, nil,
|
103
99
|
nil, nil, 0, -11, -20, -21, -20, -31, -60, -65,
|
104
|
-
-64, -18, -19, nil, 4, nil,
|
105
|
-
|
106
|
-
-
|
100
|
+
-64, -18, -19, nil, 4, nil, -18, -13, -46, 2,
|
101
|
+
-29, -31, nil, nil, nil, 9, -60, -1, -25, nil,
|
102
|
+
-38 ]
|
107
103
|
|
108
104
|
racc_goto_default = [
|
109
105
|
nil, nil, nil, 3, 4, 5, 6, 7, 8, 9,
|
110
106
|
10, 11, nil, nil, nil, nil, nil, nil, 64, nil,
|
111
|
-
nil, nil, nil, 17, nil, 18, 19, nil,
|
112
|
-
|
107
|
+
nil, nil, nil, 17, nil, 18, 19, nil, nil, 21,
|
108
|
+
53, nil, 23, 24, 59, 26, 27, nil, 29, 63,
|
113
109
|
nil ]
|
114
110
|
|
115
111
|
racc_reduce_table = [
|
@@ -162,29 +158,29 @@ racc_reduce_table = [
|
|
162
158
|
2, 39, :_reduce_46,
|
163
159
|
5, 39, :_reduce_47,
|
164
160
|
4, 39, :_reduce_48,
|
165
|
-
1,
|
166
|
-
3,
|
161
|
+
1, 59, :_reduce_49,
|
162
|
+
3, 59, :_reduce_50,
|
167
163
|
1, 56, :_reduce_51,
|
168
164
|
2, 56, :_reduce_52,
|
169
165
|
1, 56, :_reduce_none,
|
170
|
-
1,
|
171
|
-
2,
|
172
|
-
1,
|
166
|
+
1, 60, :_reduce_54,
|
167
|
+
2, 60, :_reduce_55,
|
168
|
+
1, 60, :_reduce_56,
|
173
169
|
2, 58, :_reduce_57,
|
174
170
|
3, 58, :_reduce_58,
|
175
171
|
2, 58, :_reduce_59,
|
176
172
|
1, 58, :_reduce_60,
|
177
|
-
2,
|
178
|
-
3,
|
179
|
-
1,
|
180
|
-
3,
|
173
|
+
2, 61, :_reduce_61,
|
174
|
+
3, 61, :_reduce_62,
|
175
|
+
1, 62, :_reduce_63,
|
176
|
+
3, 62, :_reduce_64,
|
181
177
|
1, 57, :_reduce_none,
|
182
178
|
1, 57, :_reduce_none,
|
183
|
-
3,
|
179
|
+
3, 64, :_reduce_67,
|
184
180
|
1, 65, :_reduce_none,
|
185
181
|
1, 65, :_reduce_none,
|
186
|
-
3,
|
187
|
-
|
182
|
+
3, 63, :_reduce_70,
|
183
|
+
2, 63, :_reduce_71,
|
188
184
|
4, 40, :_reduce_72,
|
189
185
|
2, 40, :_reduce_73,
|
190
186
|
1, 66, :_reduce_74,
|
@@ -206,7 +202,7 @@ racc_reduce_table = [
|
|
206
202
|
|
207
203
|
racc_reduce_n = 90
|
208
204
|
|
209
|
-
racc_shift_n =
|
205
|
+
racc_shift_n = 138
|
210
206
|
|
211
207
|
racc_token_table = {
|
212
208
|
false => 0,
|
@@ -322,12 +318,12 @@ Racc_token_to_s_table = [
|
|
322
318
|
"match_opts",
|
323
319
|
"match",
|
324
320
|
"more_match_opts",
|
325
|
-
"
|
326
|
-
"more_match_fixtures",
|
321
|
+
"more_matches",
|
327
322
|
"date_opts",
|
328
323
|
"geo_opts",
|
329
324
|
"geo_values",
|
330
325
|
"match_result",
|
326
|
+
"match_fixture",
|
331
327
|
"match_sep",
|
332
328
|
"goal_lines_body",
|
333
329
|
"goals",
|
@@ -761,7 +757,7 @@ module_eval(<<'.,.,', 'parser.y', 256)
|
|
761
757
|
|
762
758
|
module_eval(<<'.,.,', 'parser.y', 264)
|
763
759
|
def _reduce_67(val, _values, result)
|
764
|
-
puts "
|
760
|
+
puts " RECUDE match_fixture"
|
765
761
|
result = { team1: val[0],
|
766
762
|
team2: val[2] }
|
767
763
|
|
@@ -775,29 +771,26 @@ module_eval(<<'.,.,', 'parser.y', 264)
|
|
775
771
|
|
776
772
|
module_eval(<<'.,.,', 'parser.y', 275)
|
777
773
|
def _reduce_70(val, _values, result)
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
774
|
+
puts " REDUCE => match_result : TEXT SCORE TEXT"
|
775
|
+
result = { team1: val[0],
|
776
|
+
team2: val[2],
|
777
|
+
score: val[1][1]
|
778
|
+
}
|
783
779
|
|
784
780
|
result
|
785
781
|
end
|
786
782
|
.,.,
|
787
783
|
|
788
|
-
module_eval(<<'.,.,', 'parser.y',
|
784
|
+
module_eval(<<'.,.,', 'parser.y', 283)
|
789
785
|
def _reduce_71(val, _values, result)
|
790
|
-
|
791
|
-
|
792
|
-
team2: val[2],
|
793
|
-
score: val[3][1]
|
794
|
-
}
|
786
|
+
puts " REDUCE => match_result : match_fixture SCORE"
|
787
|
+
result = { score: val[1][1] }.merge( val[0] )
|
795
788
|
|
796
789
|
result
|
797
790
|
end
|
798
791
|
.,.,
|
799
792
|
|
800
|
-
module_eval(<<'.,.,', 'parser.y',
|
793
|
+
module_eval(<<'.,.,', 'parser.y', 302)
|
801
794
|
def _reduce_72(val, _values, result)
|
802
795
|
kwargs = val[1]
|
803
796
|
@tree << GoalLine.new( **kwargs )
|
@@ -806,7 +799,7 @@ module_eval(<<'.,.,', 'parser.y', 311)
|
|
806
799
|
end
|
807
800
|
.,.,
|
808
801
|
|
809
|
-
module_eval(<<'.,.,', 'parser.y',
|
802
|
+
module_eval(<<'.,.,', 'parser.y', 307)
|
810
803
|
def _reduce_73(val, _values, result)
|
811
804
|
kwargs = val[0]
|
812
805
|
@tree << GoalLine.new( **kwargs )
|
@@ -815,7 +808,7 @@ module_eval(<<'.,.,', 'parser.y', 316)
|
|
815
808
|
end
|
816
809
|
.,.,
|
817
810
|
|
818
|
-
module_eval(<<'.,.,', 'parser.y',
|
811
|
+
module_eval(<<'.,.,', 'parser.y', 312)
|
819
812
|
def _reduce_74(val, _values, result)
|
820
813
|
result = { goals1: val[0],
|
821
814
|
goals2: [] }
|
@@ -824,7 +817,7 @@ module_eval(<<'.,.,', 'parser.y', 321)
|
|
824
817
|
end
|
825
818
|
.,.,
|
826
819
|
|
827
|
-
module_eval(<<'.,.,', 'parser.y',
|
820
|
+
module_eval(<<'.,.,', 'parser.y', 315)
|
828
821
|
def _reduce_75(val, _values, result)
|
829
822
|
result = { goals1: [],
|
830
823
|
goals2: val[2] }
|
@@ -833,7 +826,7 @@ module_eval(<<'.,.,', 'parser.y', 324)
|
|
833
826
|
end
|
834
827
|
.,.,
|
835
828
|
|
836
|
-
module_eval(<<'.,.,', 'parser.y',
|
829
|
+
module_eval(<<'.,.,', 'parser.y', 318)
|
837
830
|
def _reduce_76(val, _values, result)
|
838
831
|
result = { goals1: val[0],
|
839
832
|
goals2: val[2] }
|
@@ -846,51 +839,51 @@ module_eval(<<'.,.,', 'parser.y', 327)
|
|
846
839
|
|
847
840
|
# reduce 78 omitted
|
848
841
|
|
849
|
-
module_eval(<<'.,.,', 'parser.y',
|
842
|
+
module_eval(<<'.,.,', 'parser.y', 332)
|
850
843
|
def _reduce_79(val, _values, result)
|
851
844
|
result = val
|
852
845
|
result
|
853
846
|
end
|
854
847
|
.,.,
|
855
848
|
|
856
|
-
module_eval(<<'.,.,', 'parser.y',
|
849
|
+
module_eval(<<'.,.,', 'parser.y', 333)
|
857
850
|
def _reduce_80(val, _values, result)
|
858
851
|
result.push( val[1])
|
859
852
|
result
|
860
853
|
end
|
861
854
|
.,.,
|
862
855
|
|
863
|
-
module_eval(<<'.,.,', 'parser.y',
|
856
|
+
module_eval(<<'.,.,', 'parser.y', 349)
|
864
857
|
def _reduce_81(val, _values, result)
|
865
|
-
|
866
|
-
|
858
|
+
result = Goal.new( player: val[0],
|
859
|
+
minutes: val[1] )
|
867
860
|
|
868
861
|
result
|
869
862
|
end
|
870
863
|
.,.,
|
871
864
|
|
872
|
-
module_eval(<<'.,.,', 'parser.y',
|
865
|
+
module_eval(<<'.,.,', 'parser.y', 361)
|
873
866
|
def _reduce_82(val, _values, result)
|
874
867
|
result = val
|
875
868
|
result
|
876
869
|
end
|
877
870
|
.,.,
|
878
871
|
|
879
|
-
module_eval(<<'.,.,', 'parser.y',
|
872
|
+
module_eval(<<'.,.,', 'parser.y', 362)
|
880
873
|
def _reduce_83(val, _values, result)
|
881
874
|
result.push( val[1])
|
882
875
|
result
|
883
876
|
end
|
884
877
|
.,.,
|
885
878
|
|
886
|
-
module_eval(<<'.,.,', 'parser.y',
|
879
|
+
module_eval(<<'.,.,', 'parser.y', 363)
|
887
880
|
def _reduce_84(val, _values, result)
|
888
881
|
result.push( val[2])
|
889
882
|
result
|
890
883
|
end
|
891
884
|
.,.,
|
892
885
|
|
893
|
-
module_eval(<<'.,.,', 'parser.y',
|
886
|
+
module_eval(<<'.,.,', 'parser.y', 369)
|
894
887
|
def _reduce_85(val, _values, result)
|
895
888
|
kwargs = {}.merge( val[0][1] )
|
896
889
|
result = Minute.new( **kwargs )
|
@@ -899,7 +892,7 @@ module_eval(<<'.,.,', 'parser.y', 362)
|
|
899
892
|
end
|
900
893
|
.,.,
|
901
894
|
|
902
|
-
module_eval(<<'.,.,', 'parser.y',
|
895
|
+
module_eval(<<'.,.,', 'parser.y', 374)
|
903
896
|
def _reduce_86(val, _values, result)
|
904
897
|
kwargs = { }.merge( val[0][1] ).merge( val[1] )
|
905
898
|
result = Minute.new( **kwargs )
|
@@ -908,21 +901,21 @@ module_eval(<<'.,.,', 'parser.y', 367)
|
|
908
901
|
end
|
909
902
|
.,.,
|
910
903
|
|
911
|
-
module_eval(<<'.,.,', 'parser.y',
|
904
|
+
module_eval(<<'.,.,', 'parser.y', 378)
|
912
905
|
def _reduce_87(val, _values, result)
|
913
906
|
result = { og: true }
|
914
907
|
result
|
915
908
|
end
|
916
909
|
.,.,
|
917
910
|
|
918
|
-
module_eval(<<'.,.,', 'parser.y',
|
911
|
+
module_eval(<<'.,.,', 'parser.y', 379)
|
919
912
|
def _reduce_88(val, _values, result)
|
920
913
|
result = { pen: true }
|
921
914
|
result
|
922
915
|
end
|
923
916
|
.,.,
|
924
917
|
|
925
|
-
module_eval(<<'.,.,', 'parser.y',
|
918
|
+
module_eval(<<'.,.,', 'parser.y', 384)
|
926
919
|
def _reduce_89(val, _values, result)
|
927
920
|
puts ' MATCH empty_line'
|
928
921
|
result
|
@@ -25,7 +25,7 @@ class Parser
|
|
25
25
|
)? # note: make penalty (P) score optional for now
|
26
26
|
(?<et1>\d{1,2}) - (?<et2>\d{1,2})
|
27
27
|
[ ]* #{ET_EN}
|
28
|
-
(?=[
|
28
|
+
(?=[ ,\]]|$)
|
29
29
|
)}ix
|
30
30
|
## todo/check: remove loakahead assertion here - why require space?
|
31
31
|
## note: \b works only after non-alphanum e.g. )
|
@@ -38,7 +38,7 @@ class Parser
|
|
38
38
|
\b
|
39
39
|
(?<p1>\d{1,2}) - (?<p2>\d{1,2})
|
40
40
|
[ ]* #{P_EN}
|
41
|
-
(?=[
|
41
|
+
(?=[ ,\]]|$)
|
42
42
|
)}ix
|
43
43
|
## todo/check: remove loakahead assertion here - why require space?
|
44
44
|
## note: \b works only after non-alphanum e.g. )
|
@@ -71,7 +71,7 @@ class Parser
|
|
71
71
|
)?
|
72
72
|
)? # note: make half time (HT) score optional for now
|
73
73
|
\)
|
74
|
-
(?=[
|
74
|
+
(?=[ ,\]]|$)
|
75
75
|
)}ix ## todo/check: remove loakahead assertion here - why require space?
|
76
76
|
## note: \b works only after non-alphanum e.g. )
|
77
77
|
|
@@ -94,7 +94,7 @@ class Parser
|
|
94
94
|
)?
|
95
95
|
)? # note: make half time (HT) score optional for now
|
96
96
|
\)
|
97
|
-
(?=[
|
97
|
+
(?=[ ,\]]|$)
|
98
98
|
)}ix ## todo/check: remove loakahead assertion here - why require space?
|
99
99
|
## note: \b works only after non-alphanum e.g. )
|
100
100
|
|
@@ -112,7 +112,7 @@ class Parser
|
|
112
112
|
(?<ht1>\d{1,2}) - (?<ht2>\d{1,2})
|
113
113
|
[ ]* \)
|
114
114
|
)? # note: make half time (HT) score optional for now
|
115
|
-
(?=[
|
115
|
+
(?=[ ,\]]|$)
|
116
116
|
)}ix ## todo/check: remove loakahead assertion here - why require space?
|
117
117
|
## note: \b works only after non-alphanum e.g. )
|
118
118
|
|
data/lib/sportdb/parser.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
## pulls in
|
2
2
|
require 'cocos'
|
3
|
-
require 'season/formats' # e.g. Season() support machinery
|
4
|
-
|
5
|
-
|
6
3
|
|
7
4
|
|
8
5
|
####
|
@@ -30,12 +27,6 @@ require_relative 'parser/tokenizer'
|
|
30
27
|
require_relative 'parser/parser'
|
31
28
|
|
32
29
|
|
33
|
-
####
|
34
|
-
## todo/check - move outline reader upstream to cocos - why? why not?
|
35
|
-
## use read_outline(), parse_outline() - why? why not?
|
36
|
-
require_relative 'parser/outline_reader'
|
37
|
-
|
38
|
-
|
39
30
|
|
40
31
|
###
|
41
32
|
# make parser api (easily) available - why? why not?
|
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.
|
4
|
+
version: 0.5.5
|
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-
|
11
|
+
date: 2025-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocos
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.4.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: season-formats
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: racc
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,7 +97,6 @@ files:
|
|
111
97
|
- config/rounds_pt.txt
|
112
98
|
- lib/sportdb/parser.rb
|
113
99
|
- lib/sportdb/parser/lang.rb
|
114
|
-
- lib/sportdb/parser/outline_reader.rb
|
115
100
|
- lib/sportdb/parser/parser.rb
|
116
101
|
- lib/sportdb/parser/token-date.rb
|
117
102
|
- lib/sportdb/parser/token-score.rb
|
@@ -1,155 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module SportDb
|
4
|
-
|
5
|
-
###
|
6
|
-
# add a simple Outline convenience class
|
7
|
-
# for processing OUtlines with OUtlineReader
|
8
|
-
|
9
|
-
class QuickMatchOutline
|
10
|
-
def self.read( path )
|
11
|
-
nodes = OutlineReader.read( path )
|
12
|
-
new( nodes )
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize( nodes )
|
16
|
-
@nodes = nodes
|
17
|
-
end
|
18
|
-
|
19
|
-
def each_para( &blk )
|
20
|
-
## note: every (new) read call - resets errors list to empty
|
21
|
-
### @errors = []
|
22
|
-
|
23
|
-
## process nodes
|
24
|
-
h1 = nil
|
25
|
-
h2 = nil
|
26
|
-
orphans = 0 ## track paragraphs's with no heading
|
27
|
-
|
28
|
-
@nodes.each do |node|
|
29
|
-
type = node[0]
|
30
|
-
|
31
|
-
if type == :h1
|
32
|
-
h1 = node[1] ## get heading text
|
33
|
-
puts " = Heading 1 >#{node[1]}<"
|
34
|
-
elsif type == :h2
|
35
|
-
if h1.nil?
|
36
|
-
puts "!! WARN - no heading for subheading; skipping processing"
|
37
|
-
next
|
38
|
-
end
|
39
|
-
h2 = node[1] ## get heading text
|
40
|
-
puts " == Heading 2 >#{node[1]}<"
|
41
|
-
elsif type == :p
|
42
|
-
if h1.nil?
|
43
|
-
orphans += 1 ## only warn once
|
44
|
-
puts "!! WARN - no heading for #{orphans} text paragraph(s); skipping parse"
|
45
|
-
next
|
46
|
-
end
|
47
|
-
|
48
|
-
lines = node[1]
|
49
|
-
blk.call( lines )
|
50
|
-
else
|
51
|
-
pp node
|
52
|
-
raise ArgumentError, "unsupported (node) type >#{type}<"
|
53
|
-
end
|
54
|
-
end # each node
|
55
|
-
end # each_para
|
56
|
-
alias_method :each_paragraph, :each_para
|
57
|
-
alias_method :each_p, :each_para
|
58
|
-
end # class QuickMatchOutline
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
class OutlineReader
|
64
|
-
|
65
|
-
def self.debug=(value) @@debug = value; end
|
66
|
-
def self.debug?() @@debug ||= false; end
|
67
|
-
def debug?() self.class.debug?; end
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
def self.read( path ) ## use - rename to read_file or from_file etc. - why? why not?
|
72
|
-
txt = File.open( path, 'r:utf-8' ) {|f| f.read }
|
73
|
-
parse( txt )
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.parse( txt )
|
77
|
-
new( txt ).parse
|
78
|
-
end
|
79
|
-
|
80
|
-
def initialize( txt )
|
81
|
-
@txt = txt
|
82
|
-
end
|
83
|
-
|
84
|
-
## note: skip "decorative" only heading e.g. ========
|
85
|
-
## todo/check: find a better name e.g. HEADING_EMPTY_RE or HEADING_LINE_RE or ???
|
86
|
-
HEADING_BLANK_RE = %r{\A
|
87
|
-
={1,}
|
88
|
-
\z}x
|
89
|
-
|
90
|
-
## note: like in wikimedia markup (and markdown) all optional trailing ==== too
|
91
|
-
HEADING_RE = %r{\A
|
92
|
-
(?<marker>={1,}) ## 1. leading ======
|
93
|
-
[ ]*
|
94
|
-
(?<text>[^=]+) ## 2. text (note: for now no "inline" = allowed)
|
95
|
-
[ ]*
|
96
|
-
=* ## 3. (optional) trailing ====
|
97
|
-
\z}x
|
98
|
-
|
99
|
-
def parse
|
100
|
-
outline=[] ## outline structure
|
101
|
-
start_para = true ## start new para(graph) on new text line?
|
102
|
-
|
103
|
-
@txt.each_line do |line|
|
104
|
-
line = line.strip ## todo/fix: keep leading and trailing spaces - why? why not?
|
105
|
-
|
106
|
-
if line.empty? ## todo/fix: keep blank line nodes?? and just remove comments and process headings?! - why? why not?
|
107
|
-
start_para = true
|
108
|
-
next
|
109
|
-
end
|
110
|
-
|
111
|
-
break if line == '__END__'
|
112
|
-
|
113
|
-
next if line.start_with?( '#' ) ## skip comments too
|
114
|
-
## strip inline (until end-of-line) comments too
|
115
|
-
## e.g Eupen | KAS Eupen ## [de]
|
116
|
-
## => Eupen | KAS Eupen
|
117
|
-
## e.g bq Bonaire, BOE # CONCACAF
|
118
|
-
## => bq Bonaire, BOE
|
119
|
-
line = line.sub( /#.*/, '' ).strip
|
120
|
-
pp line if debug?
|
121
|
-
|
122
|
-
## todo/check: also use heading blank as paragraph "breaker" or treat it like a comment ?? - why? why not?
|
123
|
-
next if HEADING_BLANK_RE.match( line ) # skip "decorative" only heading e.g. ========
|
124
|
-
|
125
|
-
## note: like in wikimedia markup (and markdown) all optional trailing ==== too
|
126
|
-
if m=HEADING_RE.match( line )
|
127
|
-
start_para = true
|
128
|
-
|
129
|
-
heading_marker = m[:marker]
|
130
|
-
heading_level = heading_marker.length ## count number of = for heading level
|
131
|
-
heading = m[:text].strip
|
132
|
-
|
133
|
-
puts "heading #{heading_level} >#{heading}<" if debug?
|
134
|
-
outline << [:"h#{heading_level}", heading]
|
135
|
-
else ## assume it's a (plain/regular) text line
|
136
|
-
if start_para
|
137
|
-
outline << [:p, [line]]
|
138
|
-
start_para = false
|
139
|
-
else
|
140
|
-
node = outline[-1] ## get last entry
|
141
|
-
if node[0] == :p ## assert it's a p(aragraph) node!!!
|
142
|
-
node[1] << line ## add line to p(aragraph)
|
143
|
-
else
|
144
|
-
puts "!! ERROR - invalid outline state / format - expected p(aragraph) node; got:"
|
145
|
-
pp node
|
146
|
-
exit 1
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
outline
|
152
|
-
end # method read
|
153
|
-
end # class OutlineReader
|
154
|
-
|
155
|
-
end # module SportDb
|