sportdb-parser 0.6.7 → 0.6.8
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 +4 -0
- data/lib/sportdb/parser/lang.rb +12 -1
- data/lib/sportdb/parser/lexer.rb +37 -1
- data/lib/sportdb/parser/parser.rb +624 -526
- data/lib/sportdb/parser/racc_tree.rb +26 -0
- data/lib/sportdb/parser/token-prop.rb +45 -18
- data/lib/sportdb/parser/token-text.rb +5 -1
- data/lib/sportdb/parser/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8d65c02b835d52ddb9f7fd61bd44dd6ff4392bd7ddcef751dcc2ec7a0934065
|
4
|
+
data.tar.gz: 92b797acbb7c1652ea50910207f86ae53fa5097bec9acaadeae96e161b005aa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dee3a2ff615fe8789593db7f627d00a1f3931d18bc150af50e75c4d68b9ad74c87dc359ebfe4268a5f974de7c681b4ddfdb4cd87e66b69b86c4fd6633c1b98a5
|
7
|
+
data.tar.gz: 54762780eb57ba090caa44c4efd53e2fcc8149c87a2aa97b7d052efc58f51da5d4f2f49cfe4ce7b1a45db437a3c9d82856cf7bb887382f75942acda6f495be4c
|
data/CHANGELOG.md
CHANGED
data/config/rounds_en.txt
CHANGED
data/lib/sportdb/parser/lang.rb
CHANGED
@@ -15,6 +15,7 @@ module Lang
|
|
15
15
|
## Group 1-99
|
16
16
|
## Group HEX # used in concaf world cup quali
|
17
17
|
## Group 1A or A1, B1 - used anywhere
|
18
|
+
## yes - A1, A2, B1, C1, etc. used in UEFA Nations League for example!!
|
18
19
|
##
|
19
20
|
## use "key" of group - why? why not?
|
20
21
|
|
@@ -197,7 +198,17 @@ end
|
|
197
198
|
|
198
199
|
|
199
200
|
def self.is_round?( text )
|
200
|
-
|
201
|
+
### note - use check for case-insensitive
|
202
|
+
## was:
|
203
|
+
## more_round_names.include?( text )
|
204
|
+
## change to:
|
205
|
+
## more_round_names.any?{ |str| str.casecmp( text )==0 }
|
206
|
+
##
|
207
|
+
## todo/fix:
|
208
|
+
## maybe in the future use our own unaccent and downcase - wyh? why not?
|
209
|
+
## note - for now ROUND_RE is also case-insensitive!!
|
210
|
+
|
211
|
+
ROUND_RE.match?( text ) || more_round_names.any?{ |str| str.casecmp( text )==0 }
|
201
212
|
end
|
202
213
|
|
203
214
|
##
|
data/lib/sportdb/parser/lexer.rb
CHANGED
@@ -344,6 +344,9 @@ def _tokenize_line( line )
|
|
344
344
|
elsif ['goals'].include?( key.downcase )
|
345
345
|
@re = PROP_GOAL_RE
|
346
346
|
tokens << [:PROP_GOALS, m[:key]]
|
347
|
+
elsif ['penalties', 'penalty shootout'].include?( key.downcase )
|
348
|
+
@re = PROP_PENALTIES_RE
|
349
|
+
tokens << [:PROP_PENALTIES, m[:key]]
|
347
350
|
else ## assume (team) line-up
|
348
351
|
@re = PROP_RE ## use LINEUP_RE ???
|
349
352
|
tokens << [:PROP, m[:key]]
|
@@ -511,6 +514,38 @@ def _tokenize_line( line )
|
|
511
514
|
puts "!!! TOKENIZE ERROR (PROP_RE) - no match found"
|
512
515
|
nil
|
513
516
|
end
|
517
|
+
elsif @re == PROP_PENALTIES_RE
|
518
|
+
if m[:space] || m[:spaces]
|
519
|
+
nil ## skip space(s)
|
520
|
+
elsif m[:prop_name] ## note - change prop_name to player
|
521
|
+
[:PROP_NAME, m[:name]] ### use PLAYER for token - why? why not?
|
522
|
+
elsif m[:enclosed_name]
|
523
|
+
## use HOLD,SAVE,POST or such keys - why? why not?
|
524
|
+
[:ENCLOSED_NAME, m[:name]]
|
525
|
+
elsif m[:score]
|
526
|
+
score = {}
|
527
|
+
## must always have ft for now e.g. 1-1 or such
|
528
|
+
### change to (generic) score from ft -
|
529
|
+
## might be score a.e.t. or such - why? why not?
|
530
|
+
score[:ft] = [m[:ft1].to_i(10),
|
531
|
+
m[:ft2].to_i(10)]
|
532
|
+
## note - for debugging keep (pass along) "literal" score
|
533
|
+
[:SCORE, [m[:score], score]]
|
534
|
+
elsif m[:sym]
|
535
|
+
sym = m[:sym]
|
536
|
+
case sym
|
537
|
+
when ',' then [:',']
|
538
|
+
when ';' then [:';']
|
539
|
+
when '[' then [:'[']
|
540
|
+
when ']' then [:']']
|
541
|
+
else
|
542
|
+
nil ## ignore others (e.g. brackets [])
|
543
|
+
end
|
544
|
+
else
|
545
|
+
## report error
|
546
|
+
puts "!!! TOKENIZE ERROR (PROP_PENALTIES_RE) - no match found"
|
547
|
+
nil
|
548
|
+
end
|
514
549
|
elsif @re == GOAL_RE || @re == PROP_GOAL_RE
|
515
550
|
if m[:space] || m[:spaces]
|
516
551
|
nil ## skip space(s)
|
@@ -715,7 +750,8 @@ def _tokenize_line( line )
|
|
715
750
|
##
|
716
751
|
## if in prop mode continue if last token is [,-]
|
717
752
|
## otherwise change back to "standard" mode
|
718
|
-
if @re == PROP_RE
|
753
|
+
if @re == PROP_RE || @re == PROP_CARDS_RE ||
|
754
|
+
@re == PROP_GOAL_RE || @re == PROP_PENALTIES_RE
|
719
755
|
if [:',', :'-', :';'].include?( tokens[-1][0] )
|
720
756
|
## continue/stay in PROP_RE mode
|
721
757
|
## todo/check - auto-add PROP_CONT token or such
|