sportdb-config 0.3.6 → 0.4.0
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/Manifest.txt +3 -0
- data/lib/sportdb/config/club_reader.rb +12 -10
- data/lib/sportdb/config/clubs.rb +121 -10
- data/lib/sportdb/config/config.rb +0 -6
- data/lib/sportdb/config/variants.rb +81 -0
- data/lib/sportdb/config/version.rb +2 -2
- data/lib/sportdb/config.rb +17 -0
- data/test/test_club_index.rb +80 -0
- data/test/test_clubs.rb +16 -36
- data/test/test_variants.rb +31 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 064b7f927038794c7d1efecde27bbba3d7ac78fa
|
4
|
+
data.tar.gz: 0dc83a80b70db77bca25e9921182fc4a1aea0466
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75d1416b8976f6bd619de196265a7ba1ac3f88c020b28489a4302732272f0e1b686f76a2dcf877e40364e240d148bf0853ba643466ff86d454060e45c9dd4da3
|
7
|
+
data.tar.gz: 1fdc13cde4020f2bc2a21da04b7df6ce25810f4f282a477862adf2af789b17d6fa009e08163fc163579478aed0ca9210588aafb09f728d2472a9711bdec90c1a
|
data/Manifest.txt
CHANGED
@@ -17,8 +17,10 @@ lib/sportdb/config/league.rb
|
|
17
17
|
lib/sportdb/config/league_reader.rb
|
18
18
|
lib/sportdb/config/league_utils.rb
|
19
19
|
lib/sportdb/config/season_utils.rb
|
20
|
+
lib/sportdb/config/variants.rb
|
20
21
|
lib/sportdb/config/version.rb
|
21
22
|
test/helper.rb
|
23
|
+
test/test_club_index.rb
|
22
24
|
test/test_club_reader.rb
|
23
25
|
test/test_clubs.rb
|
24
26
|
test/test_config.rb
|
@@ -26,3 +28,4 @@ test/test_countries.rb
|
|
26
28
|
test/test_league_reader.rb
|
27
29
|
test/test_league_utils.rb
|
28
30
|
test/test_season_utils.rb
|
31
|
+
test/test_variants.rb
|
@@ -112,16 +112,18 @@ def self.parse( txt )
|
|
112
112
|
# e.g. New York FC (2011-) => New York FC (2011-)
|
113
113
|
values = values.map { |value| value.strip.gsub( /[ \t]+/, ' ' ) }
|
114
114
|
last_rec.alt_names += values
|
115
|
+
last_rec.add_variants( values ) # auto-add (possible) auto-generated variant names
|
115
116
|
|
116
|
-
## check for duplicates
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
if count != count_uniq
|
122
|
-
puts
|
123
|
-
puts "*** !!! WARN !!! - #{count-count_uniq} duplicate alt name(s):"
|
117
|
+
## check for duplicates
|
118
|
+
if last_rec.duplicates?
|
119
|
+
duplicates = last_rec.duplicates
|
120
|
+
puts "*** !!! WARN !!! - #{duplicates.size} duplicate alt name mapping(s):"
|
121
|
+
pp duplicates
|
124
122
|
pp last_rec
|
123
|
+
##
|
124
|
+
## todo/fix: make it only an error with exit 1
|
125
|
+
## if (not normalized) names are the same (not unique/uniq)
|
126
|
+
## e.g. don't exit on A.F.C. == AFC etc.
|
125
127
|
## exit 1
|
126
128
|
end
|
127
129
|
else
|
@@ -132,7 +134,8 @@ def self.parse( txt )
|
|
132
134
|
## strip and squish (white)spaces
|
133
135
|
# e.g. New York FC (2011-) => New York FC (2011-)
|
134
136
|
value = value.strip.gsub( /[ \t]+/, ' ' )
|
135
|
-
rec.name = value
|
137
|
+
rec.name = value # canoncial name (global unique "beautiful/long" name)
|
138
|
+
rec.add_variants( value ) # auto-add (possible) auto-generated variant names
|
136
139
|
|
137
140
|
## note:
|
138
141
|
## check/todo!!!!!!!!!!!!!!!!!-
|
@@ -150,7 +153,6 @@ def self.parse( txt )
|
|
150
153
|
## e.g. New York FC (2011) => New York FC
|
151
154
|
if rec.name =~ /\(.+?\)/ ## note: use non-greedy (?) match
|
152
155
|
name = rec.name.gsub( /\(.+?\)/, '' ).strip
|
153
|
-
rec.alt_names << name
|
154
156
|
|
155
157
|
if rec.name =~ /\(([0-9]{4})-\)/ ## e.g. (2014-)
|
156
158
|
rec.year = $1.to_i
|
data/lib/sportdb/config/clubs.rb
CHANGED
@@ -9,21 +9,79 @@ module SportDb
|
|
9
9
|
# the Team struct in sportdb-text (in SportDb::Struct::Team) !!!!
|
10
10
|
class Club
|
11
11
|
## todo: use just names for alt_names - why? why not?
|
12
|
-
attr_accessor :name, :alt_names,
|
12
|
+
attr_accessor :name, :alt_names,
|
13
|
+
:year, :ground, :city
|
13
14
|
|
14
15
|
## more attribs - todo/fix - also add "upstream" to struct & model!!!!!
|
15
16
|
attr_accessor :district, :geos, :year_end, :country
|
16
17
|
|
18
|
+
## special import only attribs
|
19
|
+
attr_accessor :alt_names_auto ## auto-generated alt names
|
20
|
+
|
17
21
|
def historic?() @year_end ? true : false; end
|
18
22
|
alias_method :past?, :historic?
|
19
23
|
|
20
24
|
def initialize
|
21
|
-
@alt_names
|
25
|
+
@alt_names = []
|
26
|
+
@alt_names_auto = []
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
## helper methods for import only
|
31
|
+
## check for duplicates
|
32
|
+
def duplicates?
|
33
|
+
names = [name] + alt_names + alt_names_auto
|
34
|
+
names = names.map { |name| normalize( name ) }
|
35
|
+
|
36
|
+
names.size != names.uniq.size
|
37
|
+
end
|
38
|
+
|
39
|
+
def duplicates
|
40
|
+
names = [name] + alt_names + alt_names_auto
|
41
|
+
|
42
|
+
## calculate (count) frequency and select if greater than one
|
43
|
+
names.reduce( Hash.new ) do |h,name|
|
44
|
+
norm = normalize( name )
|
45
|
+
h[norm] ||= []
|
46
|
+
h[norm] << name; h
|
47
|
+
end.select { |norm,names| names.size > 1 }
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_variants( name_or_names )
|
51
|
+
names = name_or_names.is_a?(Array) ? name_or_names : [name_or_names]
|
52
|
+
names.each do |name|
|
53
|
+
name = sanitize( name )
|
54
|
+
self.alt_names_auto += variants( name )
|
55
|
+
end
|
22
56
|
end
|
57
|
+
|
58
|
+
private
|
59
|
+
def sanitize( name )
|
60
|
+
## check for year(s) e.g. (1887-1911), (-2013) etc.
|
61
|
+
name = name.gsub( /\([0-9\- ]+?\)/, '' ).strip
|
62
|
+
## check lang codes e.g. [en], [fr], etc.
|
63
|
+
name = name.gsub( /\[[a-z]{2}\]/, '' ).strip
|
64
|
+
name
|
65
|
+
end
|
66
|
+
|
67
|
+
def normalize( name )
|
68
|
+
name = sanitize( name)
|
69
|
+
|
70
|
+
name = name.gsub( '.', '' ) # remove all dots
|
71
|
+
## don't report duplicates that only differ with dash (-)
|
72
|
+
## e.g. Al Ahly or Al-Ahly for now - why? why not?
|
73
|
+
name = name.gsub( '-', ' ' ) # replace - with space (e.g. - same as space)
|
74
|
+
|
75
|
+
name = name.downcase ## do NOT care about upper and lowercase for now
|
76
|
+
name
|
77
|
+
end
|
78
|
+
|
79
|
+
def variants( name ) Variant.find( name ); end
|
23
80
|
end # class Club
|
24
81
|
|
25
82
|
|
26
83
|
|
84
|
+
|
27
85
|
class ClubIndex
|
28
86
|
|
29
87
|
def initialize
|
@@ -53,28 +111,60 @@ class ClubIndex
|
|
53
111
|
@clubs[ rec.name ] = rec
|
54
112
|
end
|
55
113
|
|
56
|
-
## step 2) add all names (canonical name + alt names)
|
114
|
+
## step 2) add all names (canonical name + alt names + alt names (auto))
|
57
115
|
names = [rec.name] + rec.alt_names
|
116
|
+
more_names = []
|
117
|
+
## check "hand-typed" names for year (auto-add)
|
118
|
+
## check for year(s) e.g. (1887-1911), (-2013) etc.
|
119
|
+
names.each do |name|
|
120
|
+
if name =~ /\([0-9\- ]+?\)/
|
121
|
+
more_names << name.gsub( /\([0-9\- ]+?\)/, '' ).strip
|
122
|
+
end
|
123
|
+
end
|
58
124
|
|
125
|
+
names += more_names
|
59
126
|
## check for duplicates - simple check for now - fix/improve
|
60
127
|
## todo/fix: (auto)remove duplicates - why? why not?
|
61
128
|
count = names.size
|
62
129
|
count_uniq = names.uniq.size
|
63
130
|
if count != count_uniq
|
64
131
|
puts "** !!! ERROR !!! - #{count-count_uniq} duplicate name(s):"
|
132
|
+
pp names
|
65
133
|
pp rec
|
66
134
|
exit 1
|
67
135
|
end
|
68
136
|
|
137
|
+
## check with auto-names just warn for now and do not exit
|
138
|
+
names += rec.alt_names_auto
|
139
|
+
count = names.size
|
140
|
+
count_uniq = names.uniq.size
|
141
|
+
if count != count_uniq
|
142
|
+
puts "** !!! WARN !!! - #{count-count_uniq} duplicate name(s):"
|
143
|
+
pp names
|
144
|
+
pp rec
|
145
|
+
end
|
146
|
+
|
147
|
+
|
69
148
|
names.each_with_index do |name,i|
|
70
|
-
|
149
|
+
## check lang codes e.g. [en], [fr], etc.
|
150
|
+
name = name.gsub( /\[[a-z]{2}\]/, '' ).strip
|
151
|
+
norm = normalize( name )
|
152
|
+
alt_recs = @clubs_by_name[ norm ]
|
71
153
|
if alt_recs
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
154
|
+
## check if include club rec already or is new club rec
|
155
|
+
if alt_recs.include?( rec )
|
156
|
+
## note: do NOT include duplicate club record
|
157
|
+
msg = "** !!! WARN !!! - (norm) name conflict/duplicate for club - >#{name}< normalized to >#{norm}< already included >#{rec.name}, #{rec.country.name}<"
|
158
|
+
puts msg
|
159
|
+
@errors << msg
|
160
|
+
else
|
161
|
+
msg = "** !!! WARN !!! - name conflict/duplicate - >#{name}< will overwrite >#{alt_recs[0].name}, #{alt_recs[0].country.name}< with >#{rec.name}, #{rec.country.name}<"
|
162
|
+
puts msg
|
163
|
+
@errors << msg
|
164
|
+
alt_recs << rec
|
165
|
+
end
|
76
166
|
else
|
77
|
-
@clubs_by_name[
|
167
|
+
@clubs_by_name[ norm ] = [rec]
|
78
168
|
end
|
79
169
|
end
|
80
170
|
end
|
@@ -87,6 +177,7 @@ class ClubIndex
|
|
87
177
|
|
88
178
|
def match( name )
|
89
179
|
## todo/check: return empty array if no match!!! and NOT nil (add || []) - why? why not?
|
180
|
+
name = normalize( name )
|
90
181
|
@clubs_by_name[ name ]
|
91
182
|
end
|
92
183
|
|
@@ -111,14 +202,34 @@ class ClubIndex
|
|
111
202
|
|
112
203
|
|
113
204
|
def dump_duplicates # debug helper - report duplicate club name records
|
205
|
+
@clubs.values.each do |club|
|
206
|
+
if club.duplicates?
|
207
|
+
duplicates = club.duplicates
|
208
|
+
puts "#{duplicates.size} (norm) name duplicate(s) for #{club.name}, #{club.country.name}:"
|
209
|
+
pp duplicates
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
114
213
|
@clubs_by_name.each do |name, clubs|
|
115
214
|
if clubs.size > 1
|
116
|
-
puts "#{clubs.size} duplicates for >#{name}<:"
|
215
|
+
puts "#{clubs.size} matching club duplicates for >#{name}<:"
|
117
216
|
pp clubs
|
118
217
|
end
|
119
218
|
end
|
120
219
|
end
|
121
220
|
|
221
|
+
|
222
|
+
|
223
|
+
private
|
224
|
+
def normalize( name )
|
225
|
+
name = name.gsub( '.', '' ) # remove all dots
|
226
|
+
## don't report duplicates that only differ with dash (-)
|
227
|
+
## e.g. Al Ahly or Al-Ahly for now - why? why not?
|
228
|
+
name = name.gsub( '-', ' ' ) # replace - with space (e.g. - same as space)
|
229
|
+
|
230
|
+
name = name.downcase ## do NOT care about upper and lowercase for now
|
231
|
+
name
|
232
|
+
end
|
122
233
|
end # class ClubIndex
|
123
234
|
|
124
235
|
|
@@ -6,12 +6,6 @@ module SportDb
|
|
6
6
|
|
7
7
|
class Configuration
|
8
8
|
|
9
|
-
####
|
10
|
-
# todo/fix: find a better way to configure shared test datasets
|
11
|
-
attr_accessor :test_data_dir ## todo/check: use test_dir - why? why not?
|
12
|
-
def test_data_dir() @test_data_dir ||= './datasets'; end
|
13
|
-
|
14
|
-
|
15
9
|
##
|
16
10
|
## todo: allow configure of countries_dir like clubs_dir
|
17
11
|
## "fallback" and use a default built-in world/countries.txt
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module SportDb
|
4
|
+
module Import
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
class Variant ## (spelling) variant finder / builder for names
|
9
|
+
|
10
|
+
|
11
|
+
def self.frequency_table( name ) ## todo/check: use/rename to char_frequency_table
|
12
|
+
## calculate the frequency table of letters, digits, etc.
|
13
|
+
freq = Hash.new(0)
|
14
|
+
name.each_char do |ch|
|
15
|
+
freq[ch] += 1
|
16
|
+
end
|
17
|
+
freq
|
18
|
+
end
|
19
|
+
|
20
|
+
ALPHA_SPECIALS = %w[
|
21
|
+
Ä Ö Ü
|
22
|
+
ä ö ü ß
|
23
|
+
]
|
24
|
+
|
25
|
+
## "simple" translation
|
26
|
+
SUB_ALPHA_SPECIALS = {
|
27
|
+
'Ä'=>'A', 'ä'=>'a',
|
28
|
+
'Ö'=>'O', 'ö'=>'o',
|
29
|
+
'Ü'=>'U', 'ü'=>'u',
|
30
|
+
'ß'=>'ss',
|
31
|
+
}
|
32
|
+
|
33
|
+
## de,at,ch translation for umlauts
|
34
|
+
SUB_ALPHA_SPECIALS_DE = {
|
35
|
+
'Ä'=>'Ae', 'ä'=>'ae',
|
36
|
+
'Ö'=>'Oe', 'ö'=>'oe',
|
37
|
+
'Ü'=>'Ue', 'ü'=>'ue',
|
38
|
+
'ß'=>'ss',
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
def self.alpha_specials_count( freq )
|
43
|
+
ALPHA_SPECIALS.reduce(0) do |count,ch|
|
44
|
+
count += freq[ch]
|
45
|
+
count
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.tr( name, mapping )
|
50
|
+
buf = String.new
|
51
|
+
name.each_char do |ch|
|
52
|
+
buf << if mapping[ch]
|
53
|
+
mapping[ch]
|
54
|
+
else
|
55
|
+
ch
|
56
|
+
end
|
57
|
+
end
|
58
|
+
buf
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
def self.find( name )
|
64
|
+
alt_names = []
|
65
|
+
|
66
|
+
freq = frequency_table( name )
|
67
|
+
|
68
|
+
if alpha_specials_count( freq ) > 0 # check if includes äöü etc.
|
69
|
+
alt_names << tr( name, SUB_ALPHA_SPECIALS )
|
70
|
+
alt_names << tr( name, SUB_ALPHA_SPECIALS_DE )
|
71
|
+
end
|
72
|
+
|
73
|
+
## todo - make uniq e.g. Preußen is Preussen, Preussen 2x
|
74
|
+
alt_names = alt_names.uniq
|
75
|
+
alt_names
|
76
|
+
end
|
77
|
+
end # Variant
|
78
|
+
|
79
|
+
|
80
|
+
end ## module Import
|
81
|
+
end ## module SportDb
|
@@ -7,8 +7,8 @@ module Boot ## note: use a different module than Config to avoid confusion
|
|
7
7
|
## maybe rename later gem itself to sportdb-boot - why? why not?
|
8
8
|
|
9
9
|
MAJOR = 0 ## todo: namespace inside version or something - why? why not??
|
10
|
-
MINOR =
|
11
|
-
PATCH =
|
10
|
+
MINOR = 4
|
11
|
+
PATCH = 0
|
12
12
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
13
13
|
|
14
14
|
def self.version
|
data/lib/sportdb/config.rb
CHANGED
@@ -22,6 +22,7 @@ require 'sportdb/config/league_utils'
|
|
22
22
|
require 'sportdb/config/league'
|
23
23
|
require 'sportdb/config/league_reader'
|
24
24
|
|
25
|
+
require 'sportdb/config/variants'
|
25
26
|
require 'sportdb/config/countries'
|
26
27
|
require 'sportdb/config/clubs'
|
27
28
|
require 'sportdb/config/club_reader'
|
@@ -29,4 +30,20 @@ require 'sportdb/config/config'
|
|
29
30
|
|
30
31
|
|
31
32
|
|
33
|
+
|
34
|
+
## let's put test configuration in its own namespace / module
|
35
|
+
module SportDb
|
36
|
+
|
37
|
+
class Test ## todo/check: works with module too? use a module - why? why not?
|
38
|
+
|
39
|
+
####
|
40
|
+
# todo/fix: find a better way to configure shared test datasets - why? why not?
|
41
|
+
def self.data_dir() @data_dir ||= './datasets'; end
|
42
|
+
def self.data_dir=( path ) @data_dir = path; end
|
43
|
+
end
|
44
|
+
|
45
|
+
end # module SportDb
|
46
|
+
|
47
|
+
|
48
|
+
|
32
49
|
puts SportDb::Boot.banner # say hello
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_club_index.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestClubIndex < MiniTest::Test
|
11
|
+
|
12
|
+
def test_clubs
|
13
|
+
pp SportDb::Import.config.clubs.errors
|
14
|
+
|
15
|
+
SportDb::Import.config.clubs.dump_duplicates
|
16
|
+
|
17
|
+
m = SportDb::Import.config.clubs.match( 'Rapid Wien' )
|
18
|
+
assert_equal 'SK Rapid Wien', m[0].name
|
19
|
+
assert_equal 'Austria', m[0].country.name
|
20
|
+
assert_equal 'Wien', m[0].city
|
21
|
+
|
22
|
+
m = SportDb::Import.config.clubs.match( 'rapid wien' )
|
23
|
+
assert_equal 'SK Rapid Wien', m[0].name
|
24
|
+
assert_equal 'Austria', m[0].country.name
|
25
|
+
assert_equal 'Wien', m[0].city
|
26
|
+
|
27
|
+
## note: all dots (.) get always removed
|
28
|
+
m = SportDb::Import.config.clubs.match( '...r.a.p.i.d w.i.e.n...' )
|
29
|
+
assert_equal 'SK Rapid Wien', m[0].name
|
30
|
+
assert_equal 'Austria', m[0].country.name
|
31
|
+
assert_equal 'Wien', m[0].city
|
32
|
+
|
33
|
+
m = SportDb::Import.config.clubs.match( 'RAPID WIEN' )
|
34
|
+
assert_equal 'SK Rapid Wien', m[0].name
|
35
|
+
assert_equal 'Austria', m[0].country.name
|
36
|
+
assert_equal 'Wien', m[0].city
|
37
|
+
|
38
|
+
|
39
|
+
c = SportDb::Import.config.clubs[ 'SK Rapid Wien' ] ## check canoncial name match (only)
|
40
|
+
assert_equal 'SK Rapid Wien', c.name
|
41
|
+
assert_equal 'Austria', c.country.name
|
42
|
+
assert_equal 'Wien', c.city
|
43
|
+
|
44
|
+
|
45
|
+
m = SportDb::Import.config.clubs.match( 'Arsenal' )
|
46
|
+
assert_equal 3, m.size
|
47
|
+
|
48
|
+
m = SportDb::Import.config.clubs.match( 'ARSENAL' )
|
49
|
+
assert_equal 3, m.size
|
50
|
+
|
51
|
+
m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'eng' )
|
52
|
+
assert_equal 1, m.size
|
53
|
+
assert_equal 'Arsenal FC', m[0].name
|
54
|
+
assert_equal 'England', m[0].country.name
|
55
|
+
assert_equal 'London', m[0].city
|
56
|
+
|
57
|
+
m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'ar' )
|
58
|
+
assert_equal 1, m.size
|
59
|
+
assert_equal 'Arsenal de Sarandí', m[0].name
|
60
|
+
assert_equal 'Argentina', m[0].country.name
|
61
|
+
assert_equal 'Sarandí', m[0].city
|
62
|
+
|
63
|
+
m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'ru' )
|
64
|
+
assert_equal 1, m.size
|
65
|
+
assert_equal 'Arsenal Tula', m[0].name
|
66
|
+
assert_equal 'Russia', m[0].country.name
|
67
|
+
assert_equal 'Tula', m[0].city
|
68
|
+
|
69
|
+
|
70
|
+
m = SportDb::Import.config.clubs.match( 'Arsenal FC' )
|
71
|
+
assert_equal 2, m.size
|
72
|
+
|
73
|
+
m = SportDb::Import.config.clubs.match( 'Arsenal F.C.' )
|
74
|
+
assert_equal 2, m.size
|
75
|
+
|
76
|
+
m = SportDb::Import.config.clubs.match( '...A.r.s.e.n.a.l... F.C...' )
|
77
|
+
assert_equal 2, m.size
|
78
|
+
end
|
79
|
+
|
80
|
+
end # class TestClubIndex
|
data/test/test_clubs.rb
CHANGED
@@ -9,42 +9,22 @@ require 'helper'
|
|
9
9
|
|
10
10
|
class TestClubs < MiniTest::Test
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
assert_equal
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
assert_equal
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
m = SportDb::Import.config.clubs.match( 'Arsenal' )
|
29
|
-
assert_equal 3, m.size
|
30
|
-
|
31
|
-
m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'eng' )
|
32
|
-
assert_equal 1, m.size
|
33
|
-
assert_equal 'Arsenal FC', m[0].name
|
34
|
-
assert_equal 'England', m[0].country.name
|
35
|
-
assert_equal 'London', m[0].city
|
36
|
-
|
37
|
-
m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'ar' )
|
38
|
-
assert_equal 1, m.size
|
39
|
-
assert_equal 'Arsenal de Sarandí', m[0].name
|
40
|
-
assert_equal 'Argentina', m[0].country.name
|
41
|
-
assert_equal 'Sarandí', m[0].city
|
42
|
-
|
43
|
-
m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'ru' )
|
44
|
-
assert_equal 1, m.size
|
45
|
-
assert_equal 'Arsenal Tula', m[0].name
|
46
|
-
assert_equal 'Russia', m[0].country.name
|
47
|
-
assert_equal 'Tula', m[0].city
|
12
|
+
def test_duplicats
|
13
|
+
club = SportDb::Import::Club.new
|
14
|
+
club.name = "Rapid Wien"
|
15
|
+
|
16
|
+
assert_equal false, club.duplicates?
|
17
|
+
duplicates = {}
|
18
|
+
assert_equal duplicates, club.duplicates
|
19
|
+
|
20
|
+
club.alt_names_auto += ['Rapid', 'Rapid Wien', 'SK Rapid Wien']
|
21
|
+
|
22
|
+
pp club
|
23
|
+
|
24
|
+
assert_equal true, club.duplicates?
|
25
|
+
duplicates = {'rapid wien'=>['Rapid Wien','Rapid Wien']}
|
26
|
+
pp club.duplicates
|
27
|
+
assert_equal duplicates, club.duplicates
|
48
28
|
end
|
49
29
|
|
50
30
|
end # class TestClubs
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_variants.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestVariants < MiniTest::Test
|
11
|
+
|
12
|
+
def variants( name ) SportDb::Import::Variant.find( name ); end
|
13
|
+
|
14
|
+
|
15
|
+
def test_de
|
16
|
+
assert_equal [], variants( 'Augsburg' )
|
17
|
+
|
18
|
+
assert_equal ['Koln', 'Koeln'], variants( 'Köln' )
|
19
|
+
assert_equal ['1. FC Koln', '1. FC Koeln'], variants( '1. FC Köln' )
|
20
|
+
|
21
|
+
assert_equal ['Bayern Munchen', 'Bayern Muenchen'], variants( 'Bayern München' )
|
22
|
+
assert_equal ['F. Dusseldorf', 'F. Duesseldorf'], variants( 'F. Düsseldorf' )
|
23
|
+
assert_equal ['Preussen'], variants( 'Preußen' )
|
24
|
+
assert_equal ['Munster Preussen', 'Muenster Preussen'], variants( 'Münster Preußen' )
|
25
|
+
assert_equal ['Rot-Weiss Oberhausen'], variants( 'Rot-Weiß Oberhausen' )
|
26
|
+
|
27
|
+
assert_equal ['St. Polten', 'St. Poelten'], variants( 'St. Pölten' )
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
end # class TestVariants
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: csvreader
|
@@ -86,8 +86,10 @@ files:
|
|
86
86
|
- lib/sportdb/config/league_reader.rb
|
87
87
|
- lib/sportdb/config/league_utils.rb
|
88
88
|
- lib/sportdb/config/season_utils.rb
|
89
|
+
- lib/sportdb/config/variants.rb
|
89
90
|
- lib/sportdb/config/version.rb
|
90
91
|
- test/helper.rb
|
92
|
+
- test/test_club_index.rb
|
91
93
|
- test/test_club_reader.rb
|
92
94
|
- test/test_clubs.rb
|
93
95
|
- test/test_config.rb
|
@@ -95,6 +97,7 @@ files:
|
|
95
97
|
- test/test_league_reader.rb
|
96
98
|
- test/test_league_utils.rb
|
97
99
|
- test/test_season_utils.rb
|
100
|
+
- test/test_variants.rb
|
98
101
|
homepage: https://github.com/sportdb/sport.db
|
99
102
|
licenses:
|
100
103
|
- Public Domain
|