aarimond commited on
Commit
829c4ab
·
1 Parent(s): a69f017

added scripts and readme

Browse files
Files changed (4) hide show
  1. .gitignore +4 -0
  2. README.md +1269 -1
  3. _classnames.py +87 -0
  4. lenu.py +852 -0
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ __pycache__
3
+ poetry.lock
4
+ pyproject.toml
README.md CHANGED
@@ -1,3 +1,1271 @@
1
  ---
2
- license: cc0-1.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ dataset_info:
3
+ - config_name: US-DE
4
+ features:
5
+ - name: LEI
6
+ dtype: string
7
+ - name: Entity.LegalName
8
+ dtype: string
9
+ - name: Entity.LegalForm.EntityLegalFormCode
10
+ dtype:
11
+ class_label:
12
+ names:
13
+ '0': HZEH
14
+ '1': 4FSX
15
+ '2': '8888'
16
+ '3': T91T
17
+ '4': 9ASJ
18
+ '5': XTIQ
19
+ '6': 1HXP
20
+ '7': QF4W
21
+ '8': TGMR
22
+ '9': 12N6
23
+ '10': MIPY
24
+ '11': '9999'
25
+ splits:
26
+ - name: train
27
+ num_bytes: 2538400
28
+ num_examples: 38226
29
+ - name: validation
30
+ num_bytes: 362293
31
+ num_examples: 5462
32
+ - name: test
33
+ num_bytes: 724740
34
+ num_examples: 10922
35
+ download_size: 300333753
36
+ dataset_size: 3625433
37
+ - config_name: DE
38
+ features:
39
+ - name: LEI
40
+ dtype: string
41
+ - name: Entity.LegalName
42
+ dtype: string
43
+ - name: Entity.LegalForm.EntityLegalFormCode
44
+ dtype:
45
+ class_label:
46
+ names:
47
+ '0': 2HBR
48
+ '1': 6QQB
49
+ '2': XLWA
50
+ '3': '8888'
51
+ '4': 8Z6G
52
+ '5': FR3V
53
+ '6': SGST
54
+ '7': QZ3L
55
+ '8': 40DB
56
+ '9': V2YH
57
+ '10': 63KS
58
+ '11': US8E
59
+ '12': SCE1
60
+ '13': SQKS
61
+ '14': 13AV
62
+ '15': AZFE
63
+ '16': T0YJ
64
+ '17': OL20
65
+ '18': 9JGX
66
+ '19': 79H0
67
+ '20': 2YZO
68
+ '21': YJ4C
69
+ '22': D40E
70
+ '23': 8CM0
71
+ '24': JNDX
72
+ '25': 7J3S
73
+ '26': SUA1
74
+ '27': JMVF
75
+ '28': YA01
76
+ '29': AMKW
77
+ '30': '9999'
78
+ splits:
79
+ - name: train
80
+ num_bytes: 6363812
81
+ num_examples: 95344
82
+ - name: validation
83
+ num_bytes: 909977
84
+ num_examples: 13621
85
+ - name: test
86
+ num_bytes: 1823136
87
+ num_examples: 27242
88
+ download_size: 300333753
89
+ dataset_size: 9096925
90
+ - config_name: AT
91
+ features:
92
+ - name: LEI
93
+ dtype: string
94
+ - name: Entity.LegalName
95
+ dtype: string
96
+ - name: Entity.LegalForm.EntityLegalFormCode
97
+ dtype:
98
+ class_label:
99
+ names:
100
+ '0': AXSB
101
+ '1': EQOV
102
+ '2': '8888'
103
+ '3': ONF1
104
+ '4': JTAV
105
+ '5': DX6Z
106
+ '6': ECWU
107
+ '7': 5WWO
108
+ '8': 1NOX
109
+ '9': E9OX
110
+ '10': AAL7
111
+ '11': JJYT
112
+ '12': UI81
113
+ '13': GVPD
114
+ '14': NIJH
115
+ '15': 8XDW
116
+ '16': CAQ1
117
+ '17': JQOI
118
+ '18': O65B
119
+ '19': G3R6
120
+ '20': 69H1
121
+ splits:
122
+ - name: train
123
+ num_bytes: 1130264
124
+ num_examples: 17167
125
+ - name: validation
126
+ num_bytes: 161898
127
+ num_examples: 2453
128
+ - name: test
129
+ num_bytes: 322485
130
+ num_examples: 4905
131
+ download_size: 300333753
132
+ dataset_size: 1614647
133
+ - config_name: AU
134
+ features:
135
+ - name: LEI
136
+ dtype: string
137
+ - name: Entity.LegalName
138
+ dtype: string
139
+ - name: Entity.LegalForm.EntityLegalFormCode
140
+ dtype:
141
+ class_label:
142
+ names:
143
+ '0': TXVC
144
+ '1': ADXG
145
+ '2': R4KK
146
+ '3': '8888'
147
+ '4': 7TPC
148
+ '5': LZFR
149
+ '6': Q82Q
150
+ '7': BC38
151
+ '8': XHCV
152
+ '9': PQHL
153
+ '10': J4JC
154
+ '11': 6W6X
155
+ '12': '9999'
156
+ splits:
157
+ - name: train
158
+ num_bytes: 711458
159
+ num_examples: 10737
160
+ - name: validation
161
+ num_bytes: 102011
162
+ num_examples: 1535
163
+ - name: test
164
+ num_bytes: 203149
165
+ num_examples: 3069
166
+ download_size: 300333753
167
+ dataset_size: 1016618
168
+ - config_name: CH
169
+ features:
170
+ - name: LEI
171
+ dtype: string
172
+ - name: Entity.LegalName
173
+ dtype: string
174
+ - name: Entity.LegalForm.EntityLegalFormCode
175
+ dtype:
176
+ class_label:
177
+ names:
178
+ '0': MVII
179
+ '1': '8888'
180
+ '2': 7MNN
181
+ '3': FJG4
182
+ '4': 2JZ4
183
+ '5': 54WI
184
+ '6': 3EKS
185
+ '7': FLNB
186
+ '8': XJOT
187
+ '9': H781
188
+ '10': QSI2
189
+ '11': DP2E
190
+ '12': E0NE
191
+ '13': 5BEZ
192
+ '14': AZA0
193
+ '15': 2B81
194
+ '16': M848
195
+ '17': 1BL5
196
+ '18': HX77
197
+ '19': CQMY
198
+ '20': '9999'
199
+ '21': MRSY
200
+ '22': GP8M
201
+ '23': FFTN
202
+ '24': L5DU
203
+ '25': TL87
204
+ '26': 2XJA
205
+ '27': W6A7
206
+ '28': BF9N
207
+ splits:
208
+ - name: train
209
+ num_bytes: 607674
210
+ num_examples: 9691
211
+ - name: validation
212
+ num_bytes: 87465
213
+ num_examples: 1385
214
+ - name: test
215
+ num_bytes: 173897
216
+ num_examples: 2770
217
+ download_size: 300333753
218
+ dataset_size: 869036
219
+ - config_name: CZ
220
+ features:
221
+ - name: LEI
222
+ dtype: string
223
+ - name: Entity.LegalName
224
+ dtype: string
225
+ - name: Entity.LegalForm.EntityLegalFormCode
226
+ dtype:
227
+ class_label:
228
+ names:
229
+ '0': 9HLU
230
+ '1': 6CQN
231
+ '2': TNBA
232
+ '3': 9RVC
233
+ '4': ZQO8
234
+ '5': RHFQ
235
+ '6': 747U
236
+ '7': 6D9L
237
+ '8': 3G3D
238
+ '9': 95G8
239
+ '10': SNWJ
240
+ '11': J8PB
241
+ '12': JCAD
242
+ '13': CATU
243
+ '14': CD28
244
+ '15': IQ9O
245
+ '16': HY6K
246
+ '17': UFDA
247
+ '18': QIEL
248
+ '19': 7OZQ
249
+ '20': 6FAI
250
+ '21': NI3I
251
+ '22': FY1B
252
+ '23': QQ49
253
+ '24': Q25I
254
+ '25': G2I3
255
+ '26': BL4B
256
+ '27': '9999'
257
+ '28': QJ0F
258
+ '29': 5KU5
259
+ '30': O9PW
260
+ '31': 4UB2
261
+ '32': QS6A
262
+ '33': 917C
263
+ '34': VIE3
264
+ '35': ET6Z
265
+ '36': LJL0
266
+ '37': CIO8
267
+ '38': T3Q1
268
+ '39': OVKW
269
+ '40': MAVU
270
+ '41': PFE5
271
+ '42': MBUU
272
+ '43': HQPK
273
+ '44': NQHQ
274
+ '45': XG70
275
+ '46': C4Q2
276
+ '47': NPH3
277
+ '48': '8888'
278
+ '49': D1VK
279
+ '50': VQU7
280
+ splits:
281
+ - name: train
282
+ num_bytes: 601943
283
+ num_examples: 10211
284
+ - name: validation
285
+ num_bytes: 85981
286
+ num_examples: 1459
287
+ - name: test
288
+ num_bytes: 171802
289
+ num_examples: 2918
290
+ download_size: 300333753
291
+ dataset_size: 859726
292
+ - config_name: DK
293
+ features:
294
+ - name: LEI
295
+ dtype: string
296
+ - name: Entity.LegalName
297
+ dtype: string
298
+ - name: Entity.LegalForm.EntityLegalFormCode
299
+ dtype:
300
+ class_label:
301
+ names:
302
+ '0': H8VP
303
+ '1': ZRPO
304
+ '2': 9KSX
305
+ '3': D4PU
306
+ '4': 40R4
307
+ '5': FUKI
308
+ '6': 7WRN
309
+ '7': 599X
310
+ '8': '8888'
311
+ '9': GFXN
312
+ '10': NUL8
313
+ '11': PIOI
314
+ '12': PZ6Y
315
+ '13': F7JY
316
+ '14': PMJW
317
+ '15': WU7R
318
+ '16': 1MWR
319
+ '17': 37UT
320
+ '18': GULL
321
+ '19': FW7S
322
+ '20': 5QS7
323
+ '21': '9999'
324
+ splits:
325
+ - name: train
326
+ num_bytes: 2316008
327
+ num_examples: 39743
328
+ - name: validation
329
+ num_bytes: 330461
330
+ num_examples: 5678
331
+ - name: test
332
+ num_bytes: 663327
333
+ num_examples: 11356
334
+ download_size: 300333753
335
+ dataset_size: 3309796
336
+ - config_name: EE
337
+ features:
338
+ - name: LEI
339
+ dtype: string
340
+ - name: Entity.LegalName
341
+ dtype: string
342
+ - name: Entity.LegalForm.EntityLegalFormCode
343
+ dtype:
344
+ class_label:
345
+ names:
346
+ '0': 9LJA
347
+ '1': JC0Y
348
+ '2': PRTB
349
+ '3': '8888'
350
+ '4': LVEQ
351
+ '5': 1NKP
352
+ '6': VSEV
353
+ '7': I1UP
354
+ '8': 752Q
355
+ '9': J34T
356
+ '10': LA47
357
+ '11': 3UPJ
358
+ '12': 8ZQE
359
+ splits:
360
+ - name: train
361
+ num_bytes: 490420
362
+ num_examples: 9470
363
+ - name: validation
364
+ num_bytes: 70031
365
+ num_examples: 1354
366
+ - name: test
367
+ num_bytes: 140406
368
+ num_examples: 2707
369
+ download_size: 300333753
370
+ dataset_size: 700857
371
+ - config_name: ES
372
+ features:
373
+ - name: LEI
374
+ dtype: string
375
+ - name: Entity.LegalName
376
+ dtype: string
377
+ - name: Entity.LegalForm.EntityLegalFormCode
378
+ dtype:
379
+ class_label:
380
+ names:
381
+ '0': 5RDO
382
+ '1': S0Z5
383
+ '2': DP3Q
384
+ '3': FH4R
385
+ '4': R6UT
386
+ '5': UJ35
387
+ '6': MDOL
388
+ '7': '8888'
389
+ '8': 8EHB
390
+ '9': K0RI
391
+ '10': S6MS
392
+ '11': JB2M
393
+ '12': 1G29
394
+ '13': A97B
395
+ '14': GJL1
396
+ '15': QMUM
397
+ '16': AXS5
398
+ '17': JTV5
399
+ '18': IT6N
400
+ '19': 956I
401
+ '20': 7U8O
402
+ '21': 9FPZ
403
+ '22': 1QU8
404
+ '23': TUHS
405
+ '24': I2WU
406
+ '25': A0J6
407
+ '26': S6X7
408
+ '27': 4SJR
409
+ '28': CUIH
410
+ '29': SS0L
411
+ '30': IAS6
412
+ '31': ARDP
413
+ '32': B0V5
414
+ '33': 1SL4
415
+ '34': '9999'
416
+ '35': 1ZHJ
417
+ '36': TDD5
418
+ '37': R2L8
419
+ '38': 4S57
420
+ '39': AJ9U
421
+ '40': DDES
422
+ '41': XYGP
423
+ splits:
424
+ - name: train
425
+ num_bytes: 3666811
426
+ num_examples: 59258
427
+ - name: validation
428
+ num_bytes: 522441
429
+ num_examples: 8466
430
+ - name: test
431
+ num_bytes: 1051077
432
+ num_examples: 16932
433
+ download_size: 300333753
434
+ dataset_size: 5240329
435
+ - config_name: FI
436
+ features:
437
+ - name: LEI
438
+ dtype: string
439
+ - name: Entity.LegalName
440
+ dtype: string
441
+ - name: Entity.LegalForm.EntityLegalFormCode
442
+ dtype:
443
+ class_label:
444
+ names:
445
+ '0': 5WI2
446
+ '1': K6VE
447
+ '2': DKUW
448
+ '3': UXEW
449
+ '4': '8888'
450
+ '5': NV7C
451
+ '6': K2G8
452
+ '7': 1AFG
453
+ '8': HEOB
454
+ '9': YK5G
455
+ '10': 8WJ7
456
+ '11': XJH3
457
+ '12': VOTI
458
+ '13': V0TJ
459
+ '14': 2RK5
460
+ '15': PPMX
461
+ '16': BKVI
462
+ '17': 760X
463
+ '18': 883O
464
+ '19': BKQO
465
+ '20': EE90
466
+ '21': 4H61
467
+ '22': DAFV
468
+ '23': ZMTL
469
+ '24': SJL9
470
+ '25': K09E
471
+ '26': R39F
472
+ '27': 8HGS
473
+ '28': IYF9
474
+ '29': SDPE
475
+ '30': 97PB
476
+ '31': N3LC
477
+ '32': EDZP
478
+ '33': 6PEQ
479
+ '34': DMT8
480
+ '35': SKGX
481
+ '36': Z38E
482
+ '37': KHI5
483
+ '38': MRW9
484
+ '39': T3K4
485
+ '40': HTT9
486
+ '41': SQS1
487
+ '42': 37GR
488
+ '43': OXLO
489
+ '44': R6UB
490
+ '45': 9AUC
491
+ '46': DL9Z
492
+ '47': V42B
493
+ '48': UMF0
494
+ '49': '9999'
495
+ '50': 1YIR
496
+ '51': EMC8
497
+ splits:
498
+ - name: train
499
+ num_bytes: 1397786
500
+ num_examples: 25074
501
+ - name: validation
502
+ num_bytes: 200105
503
+ num_examples: 3583
504
+ - name: test
505
+ num_bytes: 400211
506
+ num_examples: 7165
507
+ download_size: 300333753
508
+ dataset_size: 1998102
509
+ - config_name: GB
510
+ features:
511
+ - name: LEI
512
+ dtype: string
513
+ - name: Entity.LegalName
514
+ dtype: string
515
+ - name: Entity.LegalForm.EntityLegalFormCode
516
+ dtype:
517
+ class_label:
518
+ names:
519
+ '0': '8888'
520
+ '1': H0PO
521
+ '2': B6ES
522
+ '3': G12F
523
+ '4': Z0EY
524
+ '5': VV0W
525
+ '6': 57V7
526
+ '7': AVYY
527
+ '8': JTCO
528
+ '9': ID30
529
+ '10': XLZV
530
+ '11': 7T8N
531
+ '12': STX7
532
+ '13': 4GJI
533
+ '14': Q0M5
534
+ '15': 9B78
535
+ '16': 17R0
536
+ '17': E12O
537
+ '18': BX6Y
538
+ '19': IYXU
539
+ '20': WBQU
540
+ '21': NBTW
541
+ '22': 468Q
542
+ '23': 60IF
543
+ '24': 5FRT
544
+ '25': 8CF0
545
+ '26': ZZGG
546
+ '27': 4A3J
547
+ '28': '9999'
548
+ splits:
549
+ - name: train
550
+ num_bytes: 3445609
551
+ num_examples: 52626
552
+ - name: validation
553
+ num_bytes: 489952
554
+ num_examples: 7519
555
+ - name: test
556
+ num_bytes: 986783
557
+ num_examples: 15037
558
+ download_size: 300333753
559
+ dataset_size: 4922344
560
+ - config_name: HU
561
+ features:
562
+ - name: LEI
563
+ dtype: string
564
+ - name: Entity.LegalName
565
+ dtype: string
566
+ - name: Entity.LegalForm.EntityLegalFormCode
567
+ dtype:
568
+ class_label:
569
+ names:
570
+ '0': P9F2
571
+ '1': BKUX
572
+ '2': 8VH3
573
+ '3': S3DA
574
+ '4': EO9F
575
+ '5': M1DW
576
+ '6': 8UEG
577
+ '7': BJ8Q
578
+ '8': BMYJ
579
+ '9': TSVO
580
+ '10': 2A44
581
+ '11': XW5U
582
+ '12': '8888'
583
+ '13': DPY1
584
+ '14': DN6F
585
+ '15': QYV5
586
+ '16': 876R
587
+ '17': 4QRE
588
+ '18': 4WV7
589
+ '19': '9999'
590
+ '20': 4C5L
591
+ '21': ZQAQ
592
+ '22': 2LB5
593
+ '23': LNY0
594
+ '24': BSK1
595
+ '25': ESTU
596
+ '26': V3LT
597
+ '27': J6MO
598
+ '28': TQ3O
599
+ '29': X0SX
600
+ '30': UD8K
601
+ '31': Y64R
602
+ '32': 995K
603
+ '33': OII5
604
+ splits:
605
+ - name: train
606
+ num_bytes: 721420
607
+ num_examples: 7291
608
+ - name: validation
609
+ num_bytes: 102939
610
+ num_examples: 1042
611
+ - name: test
612
+ num_bytes: 206947
613
+ num_examples: 2084
614
+ download_size: 300333753
615
+ dataset_size: 1031306
616
+ - config_name: IE
617
+ features:
618
+ - name: LEI
619
+ dtype: string
620
+ - name: Entity.LegalName
621
+ dtype: string
622
+ - name: Entity.LegalForm.EntityLegalFormCode
623
+ dtype:
624
+ class_label:
625
+ names:
626
+ '0': LGWG
627
+ '1': '8888'
628
+ '2': MNQ7
629
+ '3': VYAX
630
+ '4': JXDX
631
+ '5': KMFX
632
+ '6': 2GV9
633
+ '7': C58S
634
+ '8': DWS3
635
+ '9': HNJK
636
+ '10': 5AX8
637
+ '11': 54SK
638
+ '12': LZIC
639
+ '13': URQH
640
+ '14': '9999'
641
+ '15': 9BPE
642
+ '16': FF1D
643
+ '17': ZJS8
644
+ '18': 363J
645
+ splits:
646
+ - name: train
647
+ num_bytes: 865679
648
+ num_examples: 10744
649
+ - name: validation
650
+ num_bytes: 123691
651
+ num_examples: 1535
652
+ - name: test
653
+ num_bytes: 248299
654
+ num_examples: 3070
655
+ download_size: 300333753
656
+ dataset_size: 1237669
657
+ - config_name: JP
658
+ features:
659
+ - name: LEI
660
+ dtype: string
661
+ - name: Entity.LegalName
662
+ dtype: string
663
+ - name: Entity.LegalForm.EntityLegalFormCode
664
+ dtype:
665
+ class_label:
666
+ names:
667
+ '0': T417
668
+ '1': '8888'
669
+ '2': DYQK
670
+ '3': 7QQ0
671
+ '4': N3JU
672
+ '5': R4LR
673
+ '6': '9999'
674
+ '7': IUVI
675
+ '8': MXMH
676
+ '9': 2NRQ
677
+ '10': VQLD
678
+ '11': 5MVV
679
+ splits:
680
+ - name: train
681
+ num_bytes: 603558
682
+ num_examples: 6828
683
+ - name: validation
684
+ num_bytes: 86887
685
+ num_examples: 976
686
+ - name: test
687
+ num_bytes: 172342
688
+ num_examples: 1952
689
+ download_size: 300333753
690
+ dataset_size: 862787
691
+ - config_name: KY
692
+ features:
693
+ - name: LEI
694
+ dtype: string
695
+ - name: Entity.LegalName
696
+ dtype: string
697
+ - name: Entity.LegalForm.EntityLegalFormCode
698
+ dtype:
699
+ class_label:
700
+ names:
701
+ '0': OSBR
702
+ '1': '8888'
703
+ '2': XAQA
704
+ '3': 6XB7
705
+ '4': MP7S
706
+ '5': MPUG
707
+ '6': 4XP8
708
+ '7': K575
709
+ '8': T5UM
710
+ '9': JDX6
711
+ '10': '9999'
712
+ '11': SNUK
713
+ '12': 8HR7
714
+ splits:
715
+ - name: train
716
+ num_bytes: 1026219
717
+ num_examples: 14495
718
+ - name: validation
719
+ num_bytes: 148206
720
+ num_examples: 2071
721
+ - name: test
722
+ num_bytes: 293193
723
+ num_examples: 4142
724
+ download_size: 300333753
725
+ dataset_size: 1467618
726
+ - config_name: LI
727
+ features:
728
+ - name: LEI
729
+ dtype: string
730
+ - name: Entity.LegalName
731
+ dtype: string
732
+ - name: Entity.LegalForm.EntityLegalFormCode
733
+ dtype:
734
+ class_label:
735
+ names:
736
+ '0': TV8Y
737
+ '1': TMU1
738
+ '2': BSZ8
739
+ '3': 7RRP
740
+ '4': 1DGT
741
+ '5': '8888'
742
+ '6': 53QF
743
+ '7': Y8LH
744
+ '8': IF49
745
+ '9': WAK8
746
+ '10': 32HC
747
+ '11': ANSR
748
+ '12': 1SOY
749
+ splits:
750
+ - name: train
751
+ num_bytes: 379787
752
+ num_examples: 6578
753
+ - name: validation
754
+ num_bytes: 54055
755
+ num_examples: 940
756
+ - name: test
757
+ num_bytes: 108787
758
+ num_examples: 1880
759
+ download_size: 300333753
760
+ dataset_size: 542629
761
+ - config_name: LU
762
+ features:
763
+ - name: LEI
764
+ dtype: string
765
+ - name: Entity.LegalName
766
+ dtype: string
767
+ - name: Entity.LegalForm.EntityLegalFormCode
768
+ dtype:
769
+ class_label:
770
+ names:
771
+ '0': '8888'
772
+ '1': DVXS
773
+ '2': 5GGB
774
+ '3': U8KA
775
+ '4': UDY2
776
+ '5': 81G5
777
+ '6': 63P9
778
+ '7': AIR5
779
+ '8': 2JEI
780
+ '9': SQ1A
781
+ '10': WCEP
782
+ '11': HHR4
783
+ '12': STBC
784
+ '13': V19Y
785
+ '14': '9999'
786
+ '15': V5OS
787
+ '16': 2S2U
788
+ '17': ZFFA
789
+ '18': ATQY
790
+ '19': LCR0
791
+ '20': EUT4
792
+ '21': 7SIZ
793
+ '22': BKAB
794
+ '23': 2IGL
795
+ '24': BEAN
796
+ '25': 68J6
797
+ '26': 9C91
798
+ '27': JIWD
799
+ splits:
800
+ - name: train
801
+ num_bytes: 1643123
802
+ num_examples: 23768
803
+ - name: validation
804
+ num_bytes: 235172
805
+ num_examples: 3396
806
+ - name: test
807
+ num_bytes: 469705
808
+ num_examples: 6792
809
+ download_size: 300333753
810
+ dataset_size: 2348000
811
+ - config_name: NL
812
+ features:
813
+ - name: LEI
814
+ dtype: string
815
+ - name: Entity.LegalName
816
+ dtype: string
817
+ - name: Entity.LegalForm.EntityLegalFormCode
818
+ dtype:
819
+ class_label:
820
+ names:
821
+ '0': 54M6
822
+ '1': V44D
823
+ '2': B5PM
824
+ '3': '8888'
825
+ '4': EZQW
826
+ '5': JHK5
827
+ '6': NFFH
828
+ '7': CODH
829
+ '8': 62Y3
830
+ '9': L7HX
831
+ '10': A0W7
832
+ '11': 33MN
833
+ '12': BBEB
834
+ '13': 4QXM
835
+ '14': '9999'
836
+ '15': M1IZ
837
+ '16': 9AAK
838
+ '17': DEO1
839
+ '18': GNXT
840
+ '19': UNJ2
841
+ splits:
842
+ - name: train
843
+ num_bytes: 3706306
844
+ num_examples: 62848
845
+ - name: validation
846
+ num_bytes: 530621
847
+ num_examples: 8979
848
+ - name: test
849
+ num_bytes: 1060390
850
+ num_examples: 17957
851
+ download_size: 300333753
852
+ dataset_size: 5297317
853
+ - config_name: 'NO'
854
+ features:
855
+ - name: LEI
856
+ dtype: string
857
+ - name: Entity.LegalName
858
+ dtype: string
859
+ - name: Entity.LegalForm.EntityLegalFormCode
860
+ dtype:
861
+ class_label:
862
+ names:
863
+ '0': YI42
864
+ '1': LJJW
865
+ '2': V06W
866
+ '3': '8888'
867
+ '4': IQGE
868
+ '5': 3C7U
869
+ '6': FSBD
870
+ '7': EXD7
871
+ '8': K5P8
872
+ '9': 8S9H
873
+ '10': GYY6
874
+ '11': 4ZRR
875
+ '12': 3L58
876
+ '13': R71C
877
+ '14': BJ65
878
+ '15': M9IQ
879
+ '16': O0EU
880
+ '17': CF5L
881
+ '18': 326Y
882
+ '19': ZQ0Q
883
+ '20': Q0Q1
884
+ '21': PB3V
885
+ '22': 9DI1
886
+ '23': AEV1
887
+ '24': YTMC
888
+ '25': 5ZTZ
889
+ '26': 50TD
890
+ splits:
891
+ - name: train
892
+ num_bytes: 1223064
893
+ num_examples: 23277
894
+ - name: validation
895
+ num_bytes: 174418
896
+ num_examples: 3326
897
+ - name: test
898
+ num_bytes: 349905
899
+ num_examples: 6651
900
+ download_size: 300333753
901
+ dataset_size: 1747387
902
+ - config_name: PL
903
+ features:
904
+ - name: LEI
905
+ dtype: string
906
+ - name: Entity.LegalName
907
+ dtype: string
908
+ - name: Entity.LegalForm.EntityLegalFormCode
909
+ dtype:
910
+ class_label:
911
+ names:
912
+ '0': FJ0E
913
+ '1': O7XB
914
+ '2': RBHP
915
+ '3': BSJT
916
+ '4': ZVVM
917
+ '5': '8888'
918
+ '6': OMX0
919
+ '7': 629I
920
+ '8': KM66
921
+ '9': H7OD
922
+ '10': 8TOF
923
+ '11': WUJ2
924
+ '12': T7PB
925
+ '13': 96XK
926
+ '14': ZZKE
927
+ '15': 13ZV
928
+ '16': LT9U
929
+ '17': 3BJG
930
+ '18': SVA3
931
+ '19': SP4S
932
+ '20': AL9T
933
+ '21': B21W
934
+ '22': 60BG
935
+ '23': RUCO
936
+ '24': JCKO
937
+ '25': J3A3
938
+ '26': WNX1
939
+ '27': QUX1
940
+ '28': FQ5Y
941
+ '29': 5F76
942
+ '30': WOK7
943
+ '31': QYL4
944
+ '32': GZE5
945
+ '33': SMIS
946
+ '34': CY1M
947
+ '35': YLZL
948
+ splits:
949
+ - name: train
950
+ num_bytes: 1164275
951
+ num_examples: 14167
952
+ - name: validation
953
+ num_bytes: 168331
954
+ num_examples: 2024
955
+ - name: test
956
+ num_bytes: 331549
957
+ num_examples: 4048
958
+ download_size: 300333753
959
+ dataset_size: 1664155
960
+ - config_name: SE
961
+ features:
962
+ - name: LEI
963
+ dtype: string
964
+ - name: Entity.LegalName
965
+ dtype: string
966
+ - name: Entity.LegalForm.EntityLegalFormCode
967
+ dtype:
968
+ class_label:
969
+ names:
970
+ '0': XJHM
971
+ '1': CX05
972
+ '2': '8888'
973
+ '3': BEAY
974
+ '4': BYQJ
975
+ '5': 1TN0
976
+ '6': OJ9I
977
+ '7': C61P
978
+ '8': 2UAX
979
+ '9': AZTO
980
+ '10': O1QI
981
+ '11': SSOM
982
+ '12': G04R
983
+ '13': M0Y0
984
+ '14': '9999'
985
+ '15': WZDB
986
+ '16': PDQ0
987
+ splits:
988
+ - name: train
989
+ num_bytes: 1978495
990
+ num_examples: 33687
991
+ - name: validation
992
+ num_bytes: 282253
993
+ num_examples: 4813
994
+ - name: test
995
+ num_bytes: 566233
996
+ num_examples: 9625
997
+ download_size: 300333753
998
+ dataset_size: 2826981
999
+ - config_name: US-CA
1000
+ features:
1001
+ - name: LEI
1002
+ dtype: string
1003
+ - name: Entity.LegalName
1004
+ dtype: string
1005
+ - name: Entity.LegalForm.EntityLegalFormCode
1006
+ dtype:
1007
+ class_label:
1008
+ names:
1009
+ '0': '8888'
1010
+ '1': 5HQ4
1011
+ '2': H1UM
1012
+ '3': EI4J
1013
+ '4': K7YU
1014
+ '5': SQ7B
1015
+ '6': PZR6
1016
+ '7': 7CDL
1017
+ '8': G1P6
1018
+ '9': CVXK
1019
+ '10': KQXA
1020
+ '11': 4JCS
1021
+ '12': BADE
1022
+ '13': '9999'
1023
+ splits:
1024
+ - name: train
1025
+ num_bytes: 275962
1026
+ num_examples: 4315
1027
+ - name: validation
1028
+ num_bytes: 39591
1029
+ num_examples: 617
1030
+ - name: test
1031
+ num_bytes: 79126
1032
+ num_examples: 1233
1033
+ download_size: 300333753
1034
+ dataset_size: 394679
1035
+ - config_name: US-NY
1036
+ features:
1037
+ - name: LEI
1038
+ dtype: string
1039
+ - name: Entity.LegalName
1040
+ dtype: string
1041
+ - name: Entity.LegalForm.EntityLegalFormCode
1042
+ dtype:
1043
+ class_label:
1044
+ names:
1045
+ '0': '8888'
1046
+ '1': 51RC
1047
+ '2': PJ10
1048
+ '3': SDX0
1049
+ '4': XIZI
1050
+ '5': BO6L
1051
+ '6': 4VH5
1052
+ '7': '9999'
1053
+ '8': M0ER
1054
+ '9': EPCY
1055
+ splits:
1056
+ - name: train
1057
+ num_bytes: 211229
1058
+ num_examples: 3331
1059
+ - name: validation
1060
+ num_bytes: 30484
1061
+ num_examples: 476
1062
+ - name: test
1063
+ num_bytes: 60357
1064
+ num_examples: 952
1065
+ download_size: 300333753
1066
+ dataset_size: 302070
1067
+ - config_name: VG
1068
+ features:
1069
+ - name: LEI
1070
+ dtype: string
1071
+ - name: Entity.LegalName
1072
+ dtype: string
1073
+ - name: Entity.LegalForm.EntityLegalFormCode
1074
+ dtype:
1075
+ class_label:
1076
+ names:
1077
+ '0': 6EH6
1078
+ '1': '8888'
1079
+ '2': YOP9
1080
+ '3': '9999'
1081
+ '4': Q62B
1082
+ '5': ZHED
1083
+ '6': GLCI
1084
+ '7': N28C
1085
+ '8': BST2
1086
+ '9': JS65
1087
+ splits:
1088
+ - name: train
1089
+ num_bytes: 649068
1090
+ num_examples: 10666
1091
+ - name: validation
1092
+ num_bytes: 92764
1093
+ num_examples: 1524
1094
+ - name: test
1095
+ num_bytes: 185500
1096
+ num_examples: 3048
1097
+ download_size: 300333753
1098
+ dataset_size: 927332
1099
+ - config_name: CN
1100
+ features:
1101
+ - name: LEI
1102
+ dtype: string
1103
+ - name: Entity.LegalName
1104
+ dtype: string
1105
+ - name: Entity.LegalForm.EntityLegalFormCode
1106
+ dtype:
1107
+ class_label:
1108
+ names:
1109
+ '0': ECAK
1110
+ '1': '8888'
1111
+ '2': DLEK
1112
+ '3': 1IWK
1113
+ '4': B5UZ
1114
+ '5': I39S
1115
+ '6': SH05
1116
+ '7': CYV6
1117
+ '8': 2M6Y
1118
+ '9': BDTI
1119
+ '10': V816
1120
+ '11': YXJ5
1121
+ '12': GGZ5
1122
+ '13': 8XAW
1123
+ '14': RV48
1124
+ '15': UMCR
1125
+ '16': ESZ8
1126
+ '17': 6NSC
1127
+ '18': E4FG
1128
+ '19': IBEM
1129
+ splits:
1130
+ - name: train
1131
+ num_bytes: 2485091
1132
+ num_examples: 33898
1133
+ - name: validation
1134
+ num_bytes: 354362
1135
+ num_examples: 4843
1136
+ - name: test
1137
+ num_bytes: 709914
1138
+ num_examples: 9686
1139
+ download_size: 300333753
1140
+ dataset_size: 3549367
1141
+ - config_name: ZA
1142
+ features:
1143
+ - name: LEI
1144
+ dtype: string
1145
+ - name: Entity.LegalName
1146
+ dtype: string
1147
+ - name: Entity.LegalForm.EntityLegalFormCode
1148
+ dtype:
1149
+ class_label:
1150
+ names:
1151
+ '0': GQVQ
1152
+ '1': '8888'
1153
+ '2': XE4Z
1154
+ '3': R59V
1155
+ '4': 4YUU
1156
+ '5': U89P
1157
+ '6': R155
1158
+ '7': J7L0
1159
+ splits:
1160
+ - name: train
1161
+ num_bytes: 52499
1162
+ num_examples: 795
1163
+ - name: validation
1164
+ num_bytes: 7541
1165
+ num_examples: 114
1166
+ - name: test
1167
+ num_bytes: 15198
1168
+ num_examples: 228
1169
+ download_size: 300333753
1170
+ dataset_size: 75238
1171
  ---
1172
+
1173
+ # Dataset Card for "lenu - Legal Entity Name Understanding"
1174
+
1175
+ ---------------
1176
+
1177
+ <h1 align="center">
1178
+ <a href="https://gleif.org">
1179
+ <img src="http://sdglabs.ai/wp-content/uploads/2022/07/gleif-logo-new.png" width="220px" style="display: inherit">
1180
+ </a>
1181
+ </h1><br>
1182
+ <h3 align="center">in collaboration with</h3>
1183
+ <h1 align="center">
1184
+ <a href="https://sociovestix.com">
1185
+ <img src="https://sociovestix.com/img/svl_logo_centered.svg" width="700px" style="width: 100%">
1186
+ </a>
1187
+ </h1><br>
1188
+
1189
+ ---------------
1190
+
1191
+ ## Table of Contents
1192
+ - [Dataset Card Creation Guide](#dataset-card-creation-guide)
1193
+ - [Table of Contents](#table-of-contents)
1194
+ - [Dataset Description](#dataset-description)
1195
+ - [Dataset Summary](#dataset-summary)
1196
+ - [Languages](#languages)
1197
+ - [Dataset Structure](#dataset-structure)
1198
+ - [Data Instances](#data-instances)
1199
+ - [Data Fields](#data-fields)
1200
+ - [Data Splits](#data-splits)
1201
+ - [Licensing Information](#licensing-information)
1202
+
1203
+ ## Dataset Description
1204
+
1205
+ - **Homepage:** [gleif.org](https://gleif.org)
1206
+ - **Repository:** [The LENU project](https://github.com/Sociovestix/lenu)
1207
+ - **Point of Contact:** [aarimond](https://huggingface.co/aarimond)
1208
+
1209
+ ### Dataset Summary
1210
+
1211
+ This dataset contains legal entity names from the Global LEI System in which each entity is
1212
+ assigned with a unique
1213
+ [Legal Entity Identifier](https://www.gleif.org/en/about-lei/introducing-the-legal-entity-identifier-lei)
1214
+ (LEI) code (ISO Standard 17441)
1215
+ along with their corresponding
1216
+ [Entity Legal Form (ELF) Codes](https://www.gleif.org/en/about-lei/code-lists/iso-20275-entity-legal-forms-code-list)
1217
+ (ISO Standard 20275),
1218
+ which specifies the legal form of each entity.
1219
+
1220
+ The dataset has been created as part of a collaboration of the [Global Legal Entity Identifier Foundation](https://gleif.org) (GLEIF) and
1221
+ [Sociovestix Labs](https://sociovestix.com) with the goal to explore how Machine Learning can support in detecting the ELF Code solely based on an entity's legal name and legal jurisdiction.
1222
+ See also the open source python library [lenu](https://github.com/Sociovestix/lenu), which supports in this task.
1223
+
1224
+ The data is created from LEI data downloaded from
1225
+ [GLEIF's public website](https://www.gleif.org/en/lei-data/gleif-golden-copy/download-the-golden-copy/)
1226
+ (Date: 2022-11-01 00:00), where it is accessible free of charge.
1227
+ It is divided into subsets for a selection of legal jurisdictions, whereas each Jurisdiction has its own set of ELF Codes.
1228
+ The ELF Code reference list can be downloaded [here](https://www.gleif.org/en/about-lei/code-lists/iso-20275-entity-legal-forms-code-list).
1229
+
1230
+
1231
+ ### Languages
1232
+
1233
+ The data contains several major Jurisdictions (e.g. US-DE (US Delaware), JP (Japan), DE (Germany) and others).
1234
+ Legal entity names usually follow certain language patterns, depending on which jurisdiction they are located in.
1235
+ Thus, we apply models that are pre-trained on the corresponding language.
1236
+
1237
+
1238
+ ## Dataset Structure
1239
+
1240
+ ### Data Instances
1241
+
1242
+ The data contains of the LEI, the corresponding legal name and ELF Code.
1243
+
1244
+ ```
1245
+ {
1246
+ 'LEI': '254900OMZ079O2SDWA75',
1247
+ 'Entity.LegalName': 'Park Reseda Mortgage LLC',
1248
+ 'Entity.LegalForm.EntityLegalFormCode': 0
1249
+ }
1250
+ ```
1251
+
1252
+ ### Data Fields
1253
+
1254
+ This is just a subset of available fields in the LEI system. All fields are described in detail in GLEIF's
1255
+ [LEI Common Data Format (CDF)](https://www.gleif.org/en/about-lei/common-data-file-format/current-versions/level-1-data-lei-cdf-3-1-format).
1256
+
1257
+ - `LEI`: The [Legal Entity Identifier](https://www.gleif.org/en/about-lei/introducing-the-legal-entity-identifier-lei) Code. Uniquely identifies a Legal Entity.
1258
+ - `Entity.LegalName`: The official name of the legal entity as registered in the LEI system.
1259
+ - `Entity.LegalForm.EntityLegalFormCode`: class encoded column which contains the [Entity Legal Form Code](https://www.gleif.org/en/about-lei/code-lists/iso-20275-entity-legal-forms-code-list)
1260
+
1261
+
1262
+ ### Data Splits
1263
+
1264
+ We have divided each jurisdiction's subset into stratified train (70%), validation (10%) and test (20%) splits.
1265
+ ELF Codes that appear less than three times in a Jurisdiction have been removed.
1266
+
1267
+
1268
+ ## Licensing Information
1269
+
1270
+ This dataset, which is based on LEI data, is available under Creative Commons (CC0) license.
1271
+ See [gleif.org/en/about/open-data](https://gleif.org/en/about/open-data).
_classnames.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `lenu - Legal Entity Name Understanding` by GLEIF and Sociovestix Labs
2
+ # Written in 2022 by Sociovestix Labs
3
+ # To the extent possible under law, the author(s) have dedicated all copyright
4
+ # and related and neighboring rights to this software to the public domain
5
+ # worldwide. This software is distributed without any warranty.
6
+ #
7
+ # You should have received a copy of the CC0 Public Domain Dedication along
8
+ # with this software.
9
+ # If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
10
+
11
+
12
+ """This helper script creates the classnames variable for lenu.py"""
13
+
14
+
15
+ from lenu import URL
16
+ import pandas
17
+
18
+
19
+ relevant_cols = [
20
+ "LEI",
21
+ "Entity.LegalName",
22
+ "Entity.LegalForm.EntityLegalFormCode",
23
+ "Entity.LegalJurisdiction",
24
+ "Entity.EntityCategory",
25
+ "Entity.EntityStatus",
26
+ "Registration.RegistrationStatus",
27
+ ]
28
+
29
+
30
+ COL_LEI, COL_NAME, COL_ELF, COL_JUR, COL_CAT, COL_ESTATUS, COL_RSTATUS = relevant_cols
31
+
32
+
33
+ if __name__ == "__main__":
34
+ d = pandas.read_csv(
35
+ URL,
36
+ compression="zip",
37
+ low_memory=True,
38
+ dtype=str,
39
+ # the following will prevent pandas from converting words like 'NA' to NaN. We want to work with the LEI data as is.
40
+ na_values=[""],
41
+ keep_default_na=False,
42
+ usecols=relevant_cols,
43
+ )
44
+
45
+ d_issued = d[(d[COL_ESTATUS] == "ACTIVE") & (d[COL_RSTATUS] == "ISSUED")]
46
+
47
+ classnames = {
48
+ jur: classes
49
+ for jur, classes in d_issued.groupby(COL_JUR)[COL_ELF]
50
+ .unique()
51
+ .apply(list)
52
+ .to_dict()
53
+ .items()
54
+ if jur
55
+ in [
56
+ "AT",
57
+ "AU",
58
+ "CH",
59
+ "CN",
60
+ "CZ",
61
+ "DE",
62
+ "DK",
63
+ "EE",
64
+ "ES",
65
+ "FI",
66
+ "GB",
67
+ "HU",
68
+ "IE",
69
+ "JP",
70
+ "KY",
71
+ "LU",
72
+ "NL",
73
+ "NO",
74
+ "PL",
75
+ "SE",
76
+ "US-CA",
77
+ "US-DE",
78
+ "US-NY",
79
+ "VG",
80
+ "LI",
81
+ "ZA",
82
+ ] # not CA, BE, FR, BG
83
+ }
84
+
85
+ print("Please copy the following snippet into lenu.py:")
86
+ print("")
87
+ print("classnames = ", classnames)
lenu.py ADDED
@@ -0,0 +1,852 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current
3
+ # dataset script contributor.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # NOTICE:
18
+ # this script is derivate work of
19
+ # https://github.com/huggingface/datasets/blob/main/templates/new_dataset_script.py
20
+
21
+ """lenu - Legal Entity Name Understanding"""
22
+
23
+
24
+ from io import BytesIO
25
+ import os
26
+
27
+ import datasets
28
+ from datasets.builder import logging
29
+ import fsspec
30
+ import pandas
31
+ from sklearn.model_selection import train_test_split
32
+
33
+
34
+ _DESCRIPTION = """\
35
+ This dataset contains legal entity names from the Global LEI System in
36
+ which each entity is assigned with a unique Legal Entity Identifier (LEI)
37
+ code (ISO Standard 17441) along with their corresponding Entity Legal
38
+ Form (ELF) Codes (ISO Standard 20275) which specifies the legal form of
39
+ each entity.
40
+ """
41
+ _HOMEPAGE = "gleif.org"
42
+ _LICENSE = "cc0-1.0"
43
+
44
+ URL = (
45
+ "https://goldencopy.gleif.org/api/v2/golden-copies/publishes/lei2/20221101-0000.csv"
46
+ )
47
+
48
+
49
+ # created through _classnames.py script
50
+ classnames = {
51
+ "AT": [
52
+ "AXSB",
53
+ "EQOV",
54
+ "8888",
55
+ "ONF1",
56
+ "JTAV",
57
+ "DX6Z",
58
+ "ECWU",
59
+ "5WWO",
60
+ "1NOX",
61
+ "E9OX",
62
+ "AAL7",
63
+ "JJYT",
64
+ "UI81",
65
+ "GVPD",
66
+ "NIJH",
67
+ "8XDW",
68
+ "CAQ1",
69
+ "JQOI",
70
+ "O65B",
71
+ "G3R6",
72
+ "69H1",
73
+ ],
74
+ "AU": [
75
+ "TXVC",
76
+ "ADXG",
77
+ "R4KK",
78
+ "8888",
79
+ "7TPC",
80
+ "LZFR",
81
+ "Q82Q",
82
+ "BC38",
83
+ "XHCV",
84
+ "PQHL",
85
+ "J4JC",
86
+ "6W6X",
87
+ "9999",
88
+ ],
89
+ "CH": [
90
+ "MVII",
91
+ "8888",
92
+ "7MNN",
93
+ "FJG4",
94
+ "2JZ4",
95
+ "54WI",
96
+ "3EKS",
97
+ "FLNB",
98
+ "XJOT",
99
+ "H781",
100
+ "QSI2",
101
+ "DP2E",
102
+ "E0NE",
103
+ "5BEZ",
104
+ "AZA0",
105
+ "2B81",
106
+ "M848",
107
+ "1BL5",
108
+ "HX77",
109
+ "CQMY",
110
+ "9999",
111
+ "MRSY",
112
+ "GP8M",
113
+ "FFTN",
114
+ "L5DU",
115
+ "TL87",
116
+ "2XJA",
117
+ "W6A7",
118
+ "BF9N",
119
+ ],
120
+ "CN": [
121
+ "ECAK",
122
+ "8888",
123
+ "DLEK",
124
+ "1IWK",
125
+ "B5UZ",
126
+ "I39S",
127
+ "SH05",
128
+ "CYV6",
129
+ "2M6Y",
130
+ "BDTI",
131
+ "V816",
132
+ "YXJ5",
133
+ "GGZ5",
134
+ "8XAW",
135
+ "RV48",
136
+ "UMCR",
137
+ "ESZ8",
138
+ "6NSC",
139
+ "E4FG",
140
+ "IBEM",
141
+ ],
142
+ "CZ": [
143
+ "9HLU",
144
+ "6CQN",
145
+ "TNBA",
146
+ "9RVC",
147
+ "ZQO8",
148
+ "RHFQ",
149
+ "747U",
150
+ "6D9L",
151
+ "3G3D",
152
+ "95G8",
153
+ "SNWJ",
154
+ "J8PB",
155
+ "JCAD",
156
+ "CATU",
157
+ "CD28",
158
+ "IQ9O",
159
+ "HY6K",
160
+ "UFDA",
161
+ "QIEL",
162
+ "7OZQ",
163
+ "6FAI",
164
+ "NI3I",
165
+ "FY1B",
166
+ "QQ49",
167
+ "Q25I",
168
+ "G2I3",
169
+ "BL4B",
170
+ "9999",
171
+ "QJ0F",
172
+ "5KU5",
173
+ "O9PW",
174
+ "4UB2",
175
+ "QS6A",
176
+ "917C",
177
+ "VIE3",
178
+ "ET6Z",
179
+ "LJL0",
180
+ "CIO8",
181
+ "T3Q1",
182
+ "OVKW",
183
+ "MAVU",
184
+ "PFE5",
185
+ "MBUU",
186
+ "HQPK",
187
+ "NQHQ",
188
+ "XG70",
189
+ "C4Q2",
190
+ "NPH3",
191
+ "8888",
192
+ "D1VK",
193
+ "VQU7",
194
+ ],
195
+ "DE": [
196
+ "2HBR",
197
+ "6QQB",
198
+ "XLWA",
199
+ "8888",
200
+ "8Z6G",
201
+ "FR3V",
202
+ "SGST",
203
+ "QZ3L",
204
+ "40DB",
205
+ "V2YH",
206
+ "63KS",
207
+ "US8E",
208
+ "SCE1",
209
+ "SQKS",
210
+ "13AV",
211
+ "AZFE",
212
+ "T0YJ",
213
+ "OL20",
214
+ "9JGX",
215
+ "79H0",
216
+ "2YZO",
217
+ "YJ4C",
218
+ "D40E",
219
+ "8CM0",
220
+ "JNDX",
221
+ "7J3S",
222
+ "SUA1",
223
+ "JMVF",
224
+ "YA01",
225
+ "AMKW",
226
+ "9999",
227
+ ],
228
+ "DK": [
229
+ "H8VP",
230
+ "ZRPO",
231
+ "9KSX",
232
+ "D4PU",
233
+ "40R4",
234
+ "FUKI",
235
+ "7WRN",
236
+ "599X",
237
+ "8888",
238
+ "GFXN",
239
+ "NUL8",
240
+ "PIOI",
241
+ "PZ6Y",
242
+ "F7JY",
243
+ "PMJW",
244
+ "WU7R",
245
+ "1MWR",
246
+ "37UT",
247
+ "GULL",
248
+ "FW7S",
249
+ "5QS7",
250
+ "9999",
251
+ ],
252
+ "EE": [
253
+ "9LJA",
254
+ "JC0Y",
255
+ "PRTB",
256
+ "8888",
257
+ "LVEQ",
258
+ "1NKP",
259
+ "VSEV",
260
+ "I1UP",
261
+ "752Q",
262
+ "J34T",
263
+ "LA47",
264
+ "3UPJ",
265
+ "8ZQE",
266
+ ],
267
+ "ES": [
268
+ "5RDO",
269
+ "S0Z5",
270
+ "DP3Q",
271
+ "FH4R",
272
+ "R6UT",
273
+ "UJ35",
274
+ "MDOL",
275
+ "8888",
276
+ "8EHB",
277
+ "K0RI",
278
+ "S6MS",
279
+ "JB2M",
280
+ "1G29",
281
+ "A97B",
282
+ "GJL1",
283
+ "QMUM",
284
+ "AXS5",
285
+ "JTV5",
286
+ "IT6N",
287
+ "956I",
288
+ "7U8O",
289
+ "9FPZ",
290
+ "1QU8",
291
+ "TUHS",
292
+ "I2WU",
293
+ "A0J6",
294
+ "S6X7",
295
+ "4SJR",
296
+ "CUIH",
297
+ "SS0L",
298
+ "IAS6",
299
+ "ARDP",
300
+ "B0V5",
301
+ "1SL4",
302
+ "9999",
303
+ "1ZHJ",
304
+ "TDD5",
305
+ "R2L8",
306
+ "4S57",
307
+ "AJ9U",
308
+ "DDES",
309
+ "XYGP",
310
+ ],
311
+ "FI": [
312
+ "5WI2",
313
+ "K6VE",
314
+ "DKUW",
315
+ "UXEW",
316
+ "8888",
317
+ "NV7C",
318
+ "K2G8",
319
+ "1AFG",
320
+ "HEOB",
321
+ "YK5G",
322
+ "8WJ7",
323
+ "XJH3",
324
+ "VOTI",
325
+ "V0TJ",
326
+ "2RK5",
327
+ "PPMX",
328
+ "BKVI",
329
+ "760X",
330
+ "883O",
331
+ "BKQO",
332
+ "EE90",
333
+ "4H61",
334
+ "DAFV",
335
+ "ZMTL",
336
+ "SJL9",
337
+ "K09E",
338
+ "R39F",
339
+ "8HGS",
340
+ "IYF9",
341
+ "SDPE",
342
+ "97PB",
343
+ "N3LC",
344
+ "EDZP",
345
+ "6PEQ",
346
+ "DMT8",
347
+ "SKGX",
348
+ "Z38E",
349
+ "KHI5",
350
+ "MRW9",
351
+ "T3K4",
352
+ "HTT9",
353
+ "SQS1",
354
+ "37GR",
355
+ "OXLO",
356
+ "R6UB",
357
+ "9AUC",
358
+ "DL9Z",
359
+ "V42B",
360
+ "UMF0",
361
+ "9999",
362
+ "1YIR",
363
+ "EMC8",
364
+ ],
365
+ "GB": [
366
+ "8888",
367
+ "H0PO",
368
+ "B6ES",
369
+ "G12F",
370
+ "Z0EY",
371
+ "VV0W",
372
+ "57V7",
373
+ "AVYY",
374
+ "JTCO",
375
+ "ID30",
376
+ "XLZV",
377
+ "7T8N",
378
+ "STX7",
379
+ "4GJI",
380
+ "Q0M5",
381
+ "9B78",
382
+ "17R0",
383
+ "E12O",
384
+ "BX6Y",
385
+ "IYXU",
386
+ "WBQU",
387
+ "NBTW",
388
+ "468Q",
389
+ "60IF",
390
+ "5FRT",
391
+ "8CF0",
392
+ "ZZGG",
393
+ "4A3J",
394
+ "9999",
395
+ ],
396
+ "HU": [
397
+ "P9F2",
398
+ "BKUX",
399
+ "8VH3",
400
+ "S3DA",
401
+ "EO9F",
402
+ "M1DW",
403
+ "8UEG",
404
+ "BJ8Q",
405
+ "BMYJ",
406
+ "TSVO",
407
+ "2A44",
408
+ "XW5U",
409
+ "8888",
410
+ "DPY1",
411
+ "DN6F",
412
+ "QYV5",
413
+ "876R",
414
+ "4QRE",
415
+ "4WV7",
416
+ "9999",
417
+ "4C5L",
418
+ "ZQAQ",
419
+ "2LB5",
420
+ "LNY0",
421
+ "BSK1",
422
+ "ESTU",
423
+ "V3LT",
424
+ "J6MO",
425
+ "TQ3O",
426
+ "X0SX",
427
+ "UD8K",
428
+ "Y64R",
429
+ "995K",
430
+ "OII5",
431
+ ],
432
+ "IE": [
433
+ "LGWG",
434
+ "8888",
435
+ "MNQ7",
436
+ "VYAX",
437
+ "JXDX",
438
+ "KMFX",
439
+ "2GV9",
440
+ "C58S",
441
+ "DWS3",
442
+ "HNJK",
443
+ "5AX8",
444
+ "54SK",
445
+ "LZIC",
446
+ "URQH",
447
+ "9999",
448
+ "9BPE",
449
+ "FF1D",
450
+ "ZJS8",
451
+ "363J",
452
+ ],
453
+ "JP": [
454
+ "T417",
455
+ "8888",
456
+ "DYQK",
457
+ "7QQ0",
458
+ "N3JU",
459
+ "R4LR",
460
+ "9999",
461
+ "IUVI",
462
+ "MXMH",
463
+ "2NRQ",
464
+ "VQLD",
465
+ "5MVV",
466
+ ],
467
+ "KY": [
468
+ "OSBR",
469
+ "8888",
470
+ "XAQA",
471
+ "6XB7",
472
+ "MP7S",
473
+ "MPUG",
474
+ "4XP8",
475
+ "K575",
476
+ "T5UM",
477
+ "JDX6",
478
+ "9999",
479
+ "SNUK",
480
+ "8HR7",
481
+ ],
482
+ "LI": [
483
+ "TV8Y",
484
+ "TMU1",
485
+ "BSZ8",
486
+ "7RRP",
487
+ "1DGT",
488
+ "8888",
489
+ "53QF",
490
+ "Y8LH",
491
+ "IF49",
492
+ "WAK8",
493
+ "32HC",
494
+ "ANSR",
495
+ "1SOY",
496
+ ],
497
+ "LU": [
498
+ "8888",
499
+ "DVXS",
500
+ "5GGB",
501
+ "U8KA",
502
+ "UDY2",
503
+ "81G5",
504
+ "63P9",
505
+ "AIR5",
506
+ "2JEI",
507
+ "SQ1A",
508
+ "WCEP",
509
+ "HHR4",
510
+ "STBC",
511
+ "V19Y",
512
+ "9999",
513
+ "V5OS",
514
+ "2S2U",
515
+ "ZFFA",
516
+ "ATQY",
517
+ "LCR0",
518
+ "EUT4",
519
+ "7SIZ",
520
+ "BKAB",
521
+ "2IGL",
522
+ "BEAN",
523
+ "68J6",
524
+ "9C91",
525
+ "JIWD",
526
+ ],
527
+ "NL": [
528
+ "54M6",
529
+ "V44D",
530
+ "B5PM",
531
+ "8888",
532
+ "EZQW",
533
+ "JHK5",
534
+ "NFFH",
535
+ "CODH",
536
+ "62Y3",
537
+ "L7HX",
538
+ "A0W7",
539
+ "33MN",
540
+ "BBEB",
541
+ "4QXM",
542
+ "9999",
543
+ "M1IZ",
544
+ "9AAK",
545
+ "DEO1",
546
+ "GNXT",
547
+ "UNJ2",
548
+ ],
549
+ "NO": [
550
+ "YI42",
551
+ "LJJW",
552
+ "V06W",
553
+ "8888",
554
+ "IQGE",
555
+ "3C7U",
556
+ "FSBD",
557
+ "EXD7",
558
+ "K5P8",
559
+ "8S9H",
560
+ "GYY6",
561
+ "4ZRR",
562
+ "3L58",
563
+ "R71C",
564
+ "BJ65",
565
+ "M9IQ",
566
+ "O0EU",
567
+ "CF5L",
568
+ "326Y",
569
+ "ZQ0Q",
570
+ "Q0Q1",
571
+ "PB3V",
572
+ "9DI1",
573
+ "AEV1",
574
+ "YTMC",
575
+ "5ZTZ",
576
+ "50TD",
577
+ ],
578
+ "PL": [
579
+ "FJ0E",
580
+ "O7XB",
581
+ "RBHP",
582
+ "BSJT",
583
+ "ZVVM",
584
+ "8888",
585
+ "OMX0",
586
+ "629I",
587
+ "KM66",
588
+ "H7OD",
589
+ "8TOF",
590
+ "WUJ2",
591
+ "T7PB",
592
+ "96XK",
593
+ "ZZKE",
594
+ "13ZV",
595
+ "LT9U",
596
+ "3BJG",
597
+ "SVA3",
598
+ "SP4S",
599
+ "AL9T",
600
+ "B21W",
601
+ "60BG",
602
+ "RUCO",
603
+ "JCKO",
604
+ "J3A3",
605
+ "WNX1",
606
+ "QUX1",
607
+ "FQ5Y",
608
+ "5F76",
609
+ "WOK7",
610
+ "QYL4",
611
+ "GZE5",
612
+ "SMIS",
613
+ "CY1M",
614
+ "YLZL",
615
+ ],
616
+ "SE": [
617
+ "XJHM",
618
+ "CX05",
619
+ "8888",
620
+ "BEAY",
621
+ "BYQJ",
622
+ "1TN0",
623
+ "OJ9I",
624
+ "C61P",
625
+ "2UAX",
626
+ "AZTO",
627
+ "O1QI",
628
+ "SSOM",
629
+ "G04R",
630
+ "M0Y0",
631
+ "9999",
632
+ "WZDB",
633
+ "PDQ0",
634
+ ],
635
+ "US-CA": [
636
+ "8888",
637
+ "5HQ4",
638
+ "H1UM",
639
+ "EI4J",
640
+ "K7YU",
641
+ "SQ7B",
642
+ "PZR6",
643
+ "7CDL",
644
+ "G1P6",
645
+ "CVXK",
646
+ "KQXA",
647
+ "4JCS",
648
+ "BADE",
649
+ "9999",
650
+ ],
651
+ "US-DE": [
652
+ "HZEH",
653
+ "4FSX",
654
+ "8888",
655
+ "T91T",
656
+ "9ASJ",
657
+ "XTIQ",
658
+ "1HXP",
659
+ "QF4W",
660
+ "TGMR",
661
+ "12N6",
662
+ "MIPY",
663
+ "9999",
664
+ ],
665
+ "US-NY": [
666
+ "8888",
667
+ "51RC",
668
+ "PJ10",
669
+ "SDX0",
670
+ "XIZI",
671
+ "BO6L",
672
+ "4VH5",
673
+ "9999",
674
+ "M0ER",
675
+ "EPCY",
676
+ ],
677
+ "VG": [
678
+ "6EH6",
679
+ "8888",
680
+ "YOP9",
681
+ "9999",
682
+ "Q62B",
683
+ "ZHED",
684
+ "GLCI",
685
+ "N28C",
686
+ "BST2",
687
+ "JS65",
688
+ ],
689
+ "ZA": ["GQVQ", "8888", "XE4Z", "R59V", "4YUU", "U89P", "R155", "J7L0"],
690
+ }
691
+
692
+ relevant_cols = [
693
+ "LEI",
694
+ "Entity.LegalName",
695
+ "Entity.LegalForm.EntityLegalFormCode",
696
+ "Entity.LegalJurisdiction",
697
+ "Entity.EntityCategory",
698
+ "Entity.EntityStatus",
699
+ "Registration.RegistrationStatus",
700
+ ]
701
+
702
+ COL_LEI, COL_NAME, COL_ELF, COL_JUR, COL_CAT, COL_ESTATUS, COL_RSTATUS = relevant_cols
703
+
704
+
705
+ def load_data(f, jurisdiction, compression=None):
706
+ chunks = []
707
+ with pandas.read_csv(
708
+ f,
709
+ compression=compression,
710
+ low_memory=True,
711
+ dtype=str,
712
+ # the following will prevent pandas from converting words like
713
+ # 'NA' to NaN. We want to work with the LEI data as is.
714
+ na_values=[""],
715
+ keep_default_na=False,
716
+ usecols=relevant_cols,
717
+ chunksize=100000,
718
+ ) as lei_data_reader:
719
+ for chunk in logging.tqdm(lei_data_reader, desc="Loading and preparing data.."):
720
+ # filter by jurisdiction
721
+ chunk = chunk[chunk[COL_JUR] == jurisdiction]
722
+ chunks.append(chunk)
723
+ lei_data = pandas.concat(chunks)
724
+ del chunks
725
+ return lei_data
726
+
727
+
728
+ def split_data(data, split_size=(0.7, 0.1, 0.2)):
729
+ # we apply two subsequent splits to perform a train, validation, test split
730
+ X_train_, X_test, y_train_, _ = train_test_split(
731
+ data,
732
+ data[COL_ELF],
733
+ test_size=split_size[2],
734
+ stratify=data[COL_ELF],
735
+ random_state=42,
736
+ )
737
+
738
+ X_train, X_val, _, _ = train_test_split(
739
+ X_train_,
740
+ y_train_,
741
+ test_size=split_size[1] / (split_size[0] + split_size[1]),
742
+ stratify=y_train_,
743
+ random_state=42,
744
+ )
745
+
746
+ return X_train, X_val, X_test
747
+
748
+
749
+ VERSION = datasets.Version("0.1.0")
750
+
751
+
752
+ class LENU(datasets.GeneratorBasedBuilder):
753
+ VERSION = VERSION
754
+
755
+ BUILDER_CONFIGS = [
756
+ datasets.BuilderConfig(
757
+ name=jur,
758
+ version=VERSION,
759
+ description=f"LEI data (LegalName and Entity Legal Form Code) for legal entities in Jurisdiction {jur}",
760
+ )
761
+ for jur in classnames.keys()
762
+ ]
763
+
764
+ DEFAULT_CONFIG_NAME = "US-DE"
765
+
766
+ def _info(self):
767
+ features = datasets.Features(
768
+ {
769
+ "LEI": datasets.Value("string"),
770
+ "Entity.LegalName": datasets.Value("string"),
771
+ "Entity.LegalForm.EntityLegalFormCode": datasets.features.ClassLabel(
772
+ names=classnames.get(self.config.name)
773
+ ),
774
+ }
775
+ )
776
+ return datasets.DatasetInfo(
777
+ description=_DESCRIPTION,
778
+ features=features,
779
+ # TODO check if the supervised_keys attribute makes sense here:
780
+ # supervised_keys=("sentence", "label"),
781
+ homepage=_HOMEPAGE,
782
+ license=_LICENSE,
783
+ )
784
+
785
+ def _split_generators(self, dl_manager):
786
+ checkpoint = os.path.basename(URL).replace(".csv", "")
787
+ inner_file = f"{checkpoint}-gleif-goldencopy-lei2-golden-copy.csv"
788
+ if dl_manager.is_streaming: # this means we are on the hub
789
+ # this is somewhat of a hack
790
+ with fsspec.open(URL, "rb").open() as fp:
791
+ # for some reason, handing over fp to pandas.read_csv directly
792
+ # without wrapping it into a BytesIO raises BadZipFile
793
+ fp = BytesIO(fp.read())
794
+ data_jur = load_data(fp, self.config.name, compression="zip")
795
+ else: # this would be locally
796
+ data_dir = dl_manager.download_and_extract(URL)
797
+ file_path = (
798
+ os.path.join(data_dir, inner_file)
799
+ if not data_dir.endswith(inner_file)
800
+ else data_dir
801
+ )
802
+ data_jur = load_data(file_path, self.config.name)
803
+
804
+ data_jur = data_jur[
805
+ (data_jur[COL_JUR] == self.config.name)
806
+ & (data_jur[COL_ESTATUS] == "ACTIVE")
807
+ & (data_jur[COL_RSTATUS] == "ISSUED")
808
+ ]
809
+ # data_jur[COL_ELF] = data_jur[COL_ELF].astype(str)
810
+
811
+ # filter ELF codes that appear less than 3 times
812
+ # to allow for stratified splitting
813
+ elf_counts = data_jur[COL_ELF].value_counts()
814
+ to_be_filtered = elf_counts[elf_counts >= 3].index
815
+ data_jur_filtered = data_jur[data_jur[COL_ELF].isin(to_be_filtered)]
816
+
817
+ train, val, test = split_data(data_jur_filtered)
818
+
819
+ return [
820
+ datasets.SplitGenerator(
821
+ name=datasets.Split.TRAIN,
822
+ gen_kwargs={
823
+ "data": train,
824
+ "split": "train",
825
+ },
826
+ ),
827
+ datasets.SplitGenerator(
828
+ name=datasets.Split.VALIDATION,
829
+ gen_kwargs={
830
+ "data": val,
831
+ "split": "validation",
832
+ },
833
+ ),
834
+ datasets.SplitGenerator(
835
+ name=datasets.Split.TEST,
836
+ gen_kwargs={
837
+ "data": test,
838
+ "split": "test",
839
+ },
840
+ ),
841
+ ]
842
+
843
+ def _generate_examples(self, data, split):
844
+ for i, row in data.iterrows():
845
+ yield i, {
846
+ k: row[k]
847
+ for k in [
848
+ "LEI",
849
+ "Entity.LegalName",
850
+ "Entity.LegalForm.EntityLegalFormCode",
851
+ ]
852
+ }