sportdb-formats 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Manifest.txt +6 -7
- data/Rakefile +7 -3
- data/lib/sportdb/formats/csv/goal.rb +192 -0
- data/lib/sportdb/formats/csv/goal_parser_csv.rb +28 -0
- data/lib/sportdb/formats/csv/match_parser_csv.rb +490 -0
- data/lib/sportdb/formats/csv/match_status_parser.rb +90 -0
- data/lib/sportdb/formats/match/conf_parser.rb +14 -2
- data/lib/sportdb/formats/match/match_parser.rb +502 -466
- data/lib/sportdb/formats/name_helper.rb +87 -0
- data/lib/sportdb/formats/search/sport.rb +69 -54
- data/lib/sportdb/formats/search/structs.rb +116 -0
- data/lib/sportdb/formats/search/world.rb +40 -22
- data/lib/sportdb/formats/version.rb +2 -2
- data/lib/sportdb/formats.rb +82 -15
- metadata +69 -14
- data/lib/sportdb/formats/goals.rb +0 -313
- data/lib/sportdb/formats/lines_reader.rb +0 -47
- data/lib/sportdb/formats/match/mapper.rb +0 -319
- data/lib/sportdb/formats/match/mapper_teams.rb +0 -23
- data/lib/sportdb/formats/match/match_parser_auto_conf.rb +0 -270
- data/lib/sportdb/formats/outline_reader.rb +0 -90
- data/lib/sportdb/formats/parser_helper.rb +0 -90
@@ -1,90 +0,0 @@
|
|
1
|
-
|
2
|
-
module SportDb
|
3
|
-
module ParserHelper
|
4
|
-
|
5
|
-
|
6
|
-
def read_lines( txt ) ## todo/check: add alias preproc_lines or build_lines or prep_lines etc. - why? why not?
|
7
|
-
## returns an array of lines with comments and empty lines striped / removed
|
8
|
-
lines = []
|
9
|
-
txt.each_line do |line| ## preprocess
|
10
|
-
line = line.strip
|
11
|
-
|
12
|
-
next if line.empty? || line.start_with?('#') ### skip empty lines and comments
|
13
|
-
line = line.sub( /#.*/, '' ).strip ### cut-off end-of line comments too
|
14
|
-
lines << line
|
15
|
-
end
|
16
|
-
lines
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def is_round?( line )
|
21
|
-
## note: =~ returns nil if not match found, and 0,1, etc for match
|
22
|
-
|
23
|
-
## note: allow "free standing" leg 1 and leg 2 too
|
24
|
-
## (e.g. Hinspiel, Rückspiel etc. used for now in Relegation, for example)
|
25
|
-
## note ONLY allowed if "free standing", that is, full line with nothing else
|
26
|
-
## use "custom" regex for special case for now
|
27
|
-
## avoids match HIN in PascHINg, for example (hin in german for leg 1)
|
28
|
-
line =~ SportDb.lang.regex_round ||
|
29
|
-
line =~ /^(#{SportDb.lang.leg1})$/i ||
|
30
|
-
line =~ /^(#{SportDb.lang.leg2})$/i
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
def is_knockout_round?( line )
|
35
|
-
|
36
|
-
## todo: check for adding ignore case for regex (e.g. 1st leg/1st Leg)
|
37
|
-
|
38
|
-
if line =~ SportDb.lang.regex_leg1
|
39
|
-
logger.debug " two leg knockout; skip knockout flag on first leg"
|
40
|
-
false
|
41
|
-
elsif line =~ SportDb.lang.regex_knockout_round
|
42
|
-
logger.debug " setting knockout flag to true"
|
43
|
-
true
|
44
|
-
elsif line =~ /K\.O\.|K\.o\.|Knockout/
|
45
|
-
## NB: add two language independent markers, that is, K.O. and Knockout
|
46
|
-
logger.debug " setting knockout flag to true (lang independent marker)"
|
47
|
-
true
|
48
|
-
else
|
49
|
-
false
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def is_round_def?( line )
|
54
|
-
## must include bar (|) marker (make required)
|
55
|
-
## todo/fix: use split('|') and check is_round? only on left hand side!!!! not whole line
|
56
|
-
line =~ /\|/ && is_round?( line )
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
def is_group?( line )
|
63
|
-
# note: check after is_round? (round may contain group reference!)
|
64
|
-
## note: =~ return nil if not match found, and 0,1, etc for match
|
65
|
-
(line =~ SportDb.lang.regex_group) != nil
|
66
|
-
end
|
67
|
-
|
68
|
-
def is_group_def?( line )
|
69
|
-
# note: check after is_round? (round may contain group reference!)
|
70
|
-
## must include bar (|) marker (make required)
|
71
|
-
## todo/fix: use split('|') and check is_round? only on left hand side!!!! not whole line
|
72
|
-
line =~ /\|/ && is_group?( line )
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
def is_goals?( line )
|
77
|
-
# check if is goals line
|
78
|
-
# e.g. looks like
|
79
|
-
# Neymar 29', 71' (pen.) Oscar 90+1'; Marcelo 11' (o.g.)
|
80
|
-
# check for
|
81
|
-
# <space>90' or
|
82
|
-
# <space>90+1'
|
83
|
-
|
84
|
-
line =~ /[ ](\d{1,3}\+)?\d{1,3}'/
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
end # module ParserHelper
|
89
|
-
end # module SportDb
|
90
|
-
|