fbtok 0.2.2 → 0.2.3
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/Rakefile +1 -1
- data/bin/fbchk +1 -0
- data/bin/fbtok +15 -8
- data/bin/fbtree +35 -8
- data/bin/fbx +19 -14
- data/lib/fbtok/linter.rb +19 -31
- data/lib/fbtok/opts.rb +9 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0cf5b4c14ed4e4466a769b2389e9aaf2add0fe631034010778cfc9a7671d088
|
|
4
|
+
data.tar.gz: 311e35505a4ec9b729784e4adf415888e64a855fda4a2bed3ab971a51c8ebb40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d9d1a0b0b736368613f2cae07c69ecc9fec2ca41e3b40a77471e3790ce585a4a4fb5a4559c8005deb59dee2e56fa3f489c2025033b8281910ffec8e77ad94356
|
|
7
|
+
data.tar.gz: 692715563a64d828eea4bbef1528721773dea1b7c7f4a2103079a804991fcc683ae6afff9aa76dfbf116b5050a77771c85c2ae11f5c950b402391f2eec077d5b
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
data/bin/fbchk
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
$LOAD_PATH.unshift( File.expand_path( '/sports/sportdb/sport.db/sportdb-structs/lib' ))
|
|
10
10
|
$LOAD_PATH.unshift( File.expand_path( '/sports/sportdb/sport.db/sportdb-catalogs/lib' ))
|
|
11
11
|
$LOAD_PATH.unshift( File.expand_path( '/sports/sportdb/sport.db/sportdb-search/lib' ))
|
|
12
|
+
$LOAD_PATH.unshift( File.expand_path( '/sports/sportdb/sport.db/sportdb-formats/lib' ))
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
## our own code
|
data/bin/fbtok
CHANGED
|
@@ -44,10 +44,17 @@ parser = OptionParser.new do |parser|
|
|
|
44
44
|
end
|
|
45
45
|
parser.parse!( args )
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if opts[:debug]
|
|
50
|
+
puts "OPTS:"
|
|
51
|
+
p opts
|
|
52
|
+
puts "ARGV:"
|
|
53
|
+
p args
|
|
54
|
+
|
|
55
|
+
SportDb::Parser::Linter.debug = true
|
|
56
|
+
SportDb::Parser::Opts.debug = true
|
|
57
|
+
end
|
|
51
58
|
|
|
52
59
|
|
|
53
60
|
## todo/check - use packs or projects or such
|
|
@@ -55,7 +62,8 @@ p args
|
|
|
55
62
|
specs = []
|
|
56
63
|
if opts[:file]
|
|
57
64
|
recs = read_csv( opts[:file] )
|
|
58
|
-
pp recs
|
|
65
|
+
pp recs if opts[:debug]
|
|
66
|
+
|
|
59
67
|
## note - make pathspecs relative to passed in file arg!!!
|
|
60
68
|
basedir = File.dirname( opts[:file] )
|
|
61
69
|
recs.each do |rec|
|
|
@@ -65,8 +73,8 @@ if opts[:file]
|
|
|
65
73
|
else
|
|
66
74
|
paths = if args.empty?
|
|
67
75
|
[
|
|
68
|
-
'
|
|
69
|
-
'
|
|
76
|
+
'/sports/openfootball/euro/2021--europe/euro.txt',
|
|
77
|
+
'/sports/openfootball/euro/2024--germany/euro.txt',
|
|
70
78
|
]
|
|
71
79
|
else
|
|
72
80
|
## check for directories
|
|
@@ -77,7 +85,6 @@ else
|
|
|
77
85
|
end
|
|
78
86
|
|
|
79
87
|
|
|
80
|
-
SportDb::Parser::Linter.debug = true if opts[:debug]
|
|
81
88
|
|
|
82
89
|
linter = SportDb::Parser::Linter.new
|
|
83
90
|
|
data/bin/fbtree
CHANGED
|
@@ -27,18 +27,27 @@ parser = OptionParser.new do |parser|
|
|
|
27
27
|
end
|
|
28
28
|
parser.parse!( args )
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
puts "
|
|
33
|
-
p
|
|
30
|
+
|
|
31
|
+
if opts[:debug]
|
|
32
|
+
puts "OPTS:"
|
|
33
|
+
p opts
|
|
34
|
+
puts "ARGV:"
|
|
35
|
+
p args
|
|
36
|
+
|
|
37
|
+
SportDb::Parser::Linter.debug = true
|
|
38
|
+
SportDb::Parser::Opts.debug = true
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
34
43
|
|
|
35
44
|
|
|
36
45
|
## todo/check - use packs or projects or such
|
|
37
46
|
## instead of specs - why? why not?
|
|
38
47
|
paths = if args.empty?
|
|
39
48
|
[
|
|
40
|
-
'
|
|
41
|
-
'
|
|
49
|
+
'/sports/openfootball/euro/2021--europe/euro.txt',
|
|
50
|
+
'/sports/openfootball/euro/2024--germany/euro.txt',
|
|
42
51
|
]
|
|
43
52
|
else
|
|
44
53
|
## check for directories
|
|
@@ -48,7 +57,23 @@ p args
|
|
|
48
57
|
|
|
49
58
|
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
def dump_tree_stats( tree )
|
|
61
|
+
stats = Hash.new(0) ## track counts only for now
|
|
62
|
+
tree.each do |node|
|
|
63
|
+
stats[ node.class ] += 1
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
match_count = stats[ RaccMatchParser::MatchLine ]
|
|
67
|
+
goal_count = stats[ RaccMatchParser::GoalLine ]
|
|
68
|
+
lineup_count = stats[ RaccMatchParser::LineupLine ]
|
|
69
|
+
|
|
70
|
+
puts " #{match_count} MatchLine(s)" if match_count > 0
|
|
71
|
+
puts " #{goal_count} GoalLine(s)" if goal_count > 0
|
|
72
|
+
puts " #{lineup_count} LineupLine(s)" if lineup_count > 0
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
52
77
|
|
|
53
78
|
linter = SportDb::Parser::Linter.new
|
|
54
79
|
|
|
@@ -57,7 +82,9 @@ paths.each_with_index do |path,i|
|
|
|
57
82
|
|
|
58
83
|
puts "==> [#{i+1}/#{paths.size}] reading >#{path}<..."
|
|
59
84
|
|
|
60
|
-
linter.read( path, parse: true )
|
|
85
|
+
tree = linter.read( path, parse: true )
|
|
86
|
+
|
|
87
|
+
dump_tree_stats( tree )
|
|
61
88
|
end
|
|
62
89
|
|
|
63
90
|
|
data/bin/fbx
CHANGED
|
@@ -70,12 +70,12 @@ paths = if args.empty?
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
if opts[:debug]
|
|
74
|
+
SportDb::MatchParser.debug = true
|
|
75
|
+
else
|
|
76
|
+
SportDb::MatchParser.debug = false
|
|
77
|
+
LogUtils::Logger.root.level = :info
|
|
78
|
+
end
|
|
79
79
|
|
|
80
80
|
## errors = []
|
|
81
81
|
|
|
@@ -84,16 +84,19 @@ paths.each_with_index do |path,i|
|
|
|
84
84
|
puts "==> [#{i+1}/#{paths.size}] reading >#{path}<..."
|
|
85
85
|
|
|
86
86
|
txt = read_text( path )
|
|
87
|
-
|
|
88
|
-
## pp secs
|
|
87
|
+
outline = SportDb::QuickLeagueOutline.parse( txt )
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
## todo/fix - add each_sec_with_index upstream
|
|
90
|
+
## add outline.secs.size - why? why not?
|
|
91
|
+
j = 0
|
|
92
|
+
secs_count = '?'
|
|
93
|
+
outline.each_sec do |sec| ## sec(tion)s
|
|
94
|
+
season = Season.parse( sec.season ) ## convert (str) to season obj!!!
|
|
95
|
+
league = sec.league
|
|
96
|
+
stage = sec.stage
|
|
97
|
+
lines = sec.lines
|
|
95
98
|
|
|
96
|
-
puts " section #{j+1}/#{
|
|
99
|
+
puts " section #{j+1}/#{secs_count} - #{league} #{season}, #{stage} - #{lines.size} line(s)"
|
|
97
100
|
|
|
98
101
|
next if opts[:outline]
|
|
99
102
|
|
|
@@ -130,6 +133,8 @@ paths.each_with_index do |path,i|
|
|
|
130
133
|
pp rounds
|
|
131
134
|
puts ">>> #{groups.size} groups:"
|
|
132
135
|
pp groups
|
|
136
|
+
|
|
137
|
+
j += 1
|
|
133
138
|
end # each secs
|
|
134
139
|
end # each paths
|
|
135
140
|
|
data/lib/fbtok/linter.rb
CHANGED
|
@@ -30,18 +30,19 @@ def read( path, parse: true )
|
|
|
30
30
|
## note: every (new) read call - resets errors list to empty
|
|
31
31
|
@errors = []
|
|
32
32
|
|
|
33
|
+
@tree = []
|
|
34
|
+
|
|
33
35
|
outline = QuickMatchOutline.read( path )
|
|
34
36
|
|
|
35
37
|
outline.each_para do |lines|
|
|
36
38
|
|
|
37
39
|
if parse
|
|
38
|
-
## flatten lines
|
|
39
|
-
txt =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
txt = txt.join
|
|
40
|
+
## flatten lines (array of strings) into all-in-one string
|
|
41
|
+
txt = lines.reduce( String.new ) do |mem, line|
|
|
42
|
+
mem << line
|
|
43
|
+
mem << "\n"
|
|
44
|
+
mem
|
|
45
|
+
end
|
|
45
46
|
|
|
46
47
|
if debug?
|
|
47
48
|
puts "lines:"
|
|
@@ -49,12 +50,18 @@ def read( path, parse: true )
|
|
|
49
50
|
end
|
|
50
51
|
|
|
51
52
|
## todo/fix - add/track parse errors!!!!!!
|
|
53
|
+
## pass along debug flag to parser (& tokenizer)?
|
|
52
54
|
parser = RaccMatchParser.new( txt ) ## use own parser instance (not shared) - why? why not?
|
|
53
55
|
tree = parser.parse
|
|
54
|
-
|
|
56
|
+
|
|
57
|
+
if debug?
|
|
58
|
+
puts "parse tree:"
|
|
59
|
+
pp tree
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
@tree += tree ## add nodes
|
|
55
63
|
|
|
56
64
|
else ## process for tokenize only
|
|
57
|
-
tree = []
|
|
58
65
|
lines.each_with_index do |line,i|
|
|
59
66
|
|
|
60
67
|
if debug?
|
|
@@ -75,32 +82,13 @@ def read( path, parse: true )
|
|
|
75
82
|
end
|
|
76
83
|
end
|
|
77
84
|
|
|
78
|
-
## post-process tokens
|
|
79
|
-
## - check for round, group, etc.
|
|
80
|
-
t = t.map do |tok|
|
|
81
|
-
#############
|
|
82
|
-
## pass 1
|
|
83
|
-
## replace all texts with keyword matches (e.g. group, round, leg, etc.)
|
|
84
|
-
if tok[0] == :TEXT
|
|
85
|
-
text = tok[1]
|
|
86
|
-
if @parser.is_group?( text )
|
|
87
|
-
[:GROUP, text]
|
|
88
|
-
elsif @parser.is_round?( text ) || @parser.is_leg?( text )
|
|
89
|
-
[:ROUND, text]
|
|
90
|
-
else
|
|
91
|
-
tok ## pass through as-is (1:1)
|
|
92
|
-
end
|
|
93
|
-
else
|
|
94
|
-
tok
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
85
|
pp t if debug?
|
|
99
|
-
|
|
100
|
-
tree << t
|
|
101
86
|
end # each line
|
|
102
87
|
end # parse? (or tokenize?)
|
|
103
88
|
end # each para (node)
|
|
89
|
+
|
|
90
|
+
## note - only returns pare tree for now; no tokens (on parse=false)
|
|
91
|
+
@tree ## return parse tree
|
|
104
92
|
end # method read
|
|
105
93
|
end # class Linter
|
|
106
94
|
|
data/lib/fbtok/opts.rb
CHANGED
|
@@ -7,6 +7,10 @@ class Parser
|
|
|
7
7
|
## note - Opts Helpers for now nested inside Parser - keep here? why? why not?
|
|
8
8
|
class Opts
|
|
9
9
|
|
|
10
|
+
def self.debug=(value) @@debug = value; end
|
|
11
|
+
def self.debug?() @@debug ||= false; end ## note: default is FALSE
|
|
12
|
+
|
|
13
|
+
|
|
10
14
|
SEASON_RE = %r{ (?:
|
|
11
15
|
\d{4}-\d{2}
|
|
12
16
|
| \d{4}(--[a-z0-9_-]+)?
|
|
@@ -63,9 +67,11 @@ def self.expand_args( args )
|
|
|
63
67
|
## check if directory
|
|
64
68
|
if Dir.exist?( arg )
|
|
65
69
|
datafiles = find( arg )
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
if debug?
|
|
71
|
+
puts
|
|
72
|
+
puts " found #{datafiles.size} match txt datafiles in #{arg}"
|
|
73
|
+
pp datafiles
|
|
74
|
+
end
|
|
69
75
|
paths += datafiles
|
|
70
76
|
else
|
|
71
77
|
## assume it's a file
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fbtok
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
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-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sportdb-parser
|