JP-SystemsX commited on
Commit
e26c06b
1 Parent(s): 7af7df3

Clean Up + Minor Error Handling

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. super_eurlex.py +19 -37
.gitignore CHANGED
@@ -4,3 +4,4 @@ requirements.txt
4
  parquet_converter.py
5
  text_data3/
6
  meta_data3/
 
 
4
  parquet_converter.py
5
  text_data3/
6
  meta_data3/
7
+ *.pyc
super_eurlex.py CHANGED
@@ -48,35 +48,15 @@ _URLS = {
48
  "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
49
  }
50
  AVAILABLE_LANGUAGES=['DE']#, 'EN'
51
- SECTORS=['0', '1', '2', '3', '4', '5', '6', '8', '9', 'C', 'E']
52
 
53
  # Features to override the standard most Features were scrapped as a sequence
54
  # of strings with only the following exceptions
55
  FEATURES = {
56
  'celex_id': datasets.Value("string"),
57
- 'current_consolidated_version': datasets.Sequence(datasets.Value("string")),
58
- 'customs_duties_authorisation_to_defer_application_of_cct': datasets.Sequence(datasets.Value("string")),
59
- 'customs_duties_community_tariff_quotas': datasets.Sequence(datasets.Value("string")),
60
- 'customs_duties_suspensions': datasets.Sequence(datasets.Value("string")),
61
- 'directory_code': datasets.Sequence(datasets.Value("string")),
62
- 'eurovoc': datasets.Sequence(datasets.Value("string")),
63
- 'form': datasets.Sequence(datasets.Value("string")),
64
- 'harmonisation_of_customs_law_community_transit': datasets.Sequence(datasets.Value("string")),
65
- 'harmonisation_of_customs_law_customs_territory': datasets.Sequence(datasets.Value("string")),
66
- 'harmonisation_of_customs_law_origin_of_goods': datasets.Sequence(datasets.Value("string")),
67
- 'harmonisation_of_customs_law_value_for_customs_purposes': datasets.Sequence(datasets.Value("string")),
68
- 'harmonisation_of_customs_law_various': datasets.Sequence(datasets.Value("string")),
69
- 'subject_matter': datasets.Sequence(datasets.Value("string")),
70
  'text_cleaned': datasets.Value("string"),
71
  'text_html_cleaned': datasets.Value("string"),
72
  'text_html_raw': datasets.Value("string"),
73
- '02.40.10.20_customs_union_and_free_movement_of_goods_/_specific_customs_rules_/_movement_of_goods_/_extra-community_trade_efta_agreements':datasets.Sequence(datasets.Value("string")),
74
- '13.20.40.00_industrial_policy_and_internal_market_/_industrial_policy_sectoral_operations_/_textiles':datasets.Sequence(datasets.Value("string")),
75
- '13.20.60.00_industrial_policy_and_internal_market_/_industrial_policy_sectoral_operations_/_information_technology,_telecommunications_and_data-processing':datasets.Sequence(datasets.Value("string")),
76
- '13.10.30.00_industrial_policy_and_internal_market_/_industrial_policy_general,_programmes,_statistics_and_research_/_research_and_technological_development':datasets.Sequence(datasets.Value("string")),
77
- '13.10.30.10_industrial_policy_and_internal_market_/_industrial_policy_general,_programmes,_statistics_and_research_/_research_and_technological_development_/_general_principles': datasets.Sequence(datasets.Value("string")),
78
- '13.30.19.00_industrial_policy_and_internal_market_/_internal_market_approximation_of_laws_/_fertilisers': datasets.Sequence(datasets.Value("string")),
79
- '13.10.30.20_industrial_policy_and_internal_market_/_industrial_policy_general,_programmes,_statistics_and_research_/_research_and_technological_development_/_research_sectors': datasets.Sequence(datasets.Value("string")),
80
  }
81
  FEATURES_IN_SECTOR={
82
  '0':['celex_id', 'text_html_raw', 'text_html_cleaned', 'text_cleaned', 'form'],
@@ -310,18 +290,18 @@ FEATURES_IN_SECTOR={
310
  AVAILABLE_FEATURES={sector: datasets.Features({feature:(FEATURES[feature] if feature in FEATURES else datasets.Sequence(datasets.Value("string"))) for feature in FEATURES_IN_SECTOR[sector]}) for sector in SECTORS}
311
 
312
  SECTOR_DESCRIPTIONS={
313
- '0':"",
314
- '1':"",
315
- '2':"",
316
- '3':"",
317
- '4':"",
318
- '5':"",
319
- '6':"",
320
- '7':"",
321
- '8':"",
322
- '9':"",
323
- 'C':"",
324
- 'E':"",
325
  }
326
 
327
 
@@ -376,7 +356,7 @@ class SuperEurlex(datasets.GeneratorBasedBuilder):
376
  for lang in AVAILABLE_LANGUAGES for sect in SECTORS
377
  ]
378
 
379
- DEFAULT_CONFIG_NAME = "3.DE" # It's not mandatory to have a default configuration. Just use one if it make sense.
380
 
381
  def _info(self):
382
  # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
@@ -407,7 +387,11 @@ class SuperEurlex(datasets.GeneratorBasedBuilder):
407
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
408
  urls = {'text': self.config.text_data_url,
409
  'meta': self.config.meta_data_url} #_URLS[self.config.name]
410
- data_dir = dl_manager.download_and_extract(urls)
 
 
 
 
411
  return [
412
  datasets.SplitGenerator(
413
  name=datasets.Split.TRAIN,
@@ -437,8 +421,6 @@ class SuperEurlex(datasets.GeneratorBasedBuilder):
437
  yield i, sample
438
 
439
 
440
-
441
- print("Hello World")
442
  if __name__ == '__main__':
443
  import datasets as ds
444
  import sys
 
48
  "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
49
  }
50
  AVAILABLE_LANGUAGES=['DE']#, 'EN'
51
+ SECTORS=['0', '1', '2', '3', '4', '5', '6', '8', '9', 'C', 'E']#'7',
52
 
53
  # Features to override the standard most Features were scrapped as a sequence
54
  # of strings with only the following exceptions
55
  FEATURES = {
56
  'celex_id': datasets.Value("string"),
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  'text_cleaned': datasets.Value("string"),
58
  'text_html_cleaned': datasets.Value("string"),
59
  'text_html_raw': datasets.Value("string"),
 
 
 
 
 
 
 
60
  }
61
  FEATURES_IN_SECTOR={
62
  '0':['celex_id', 'text_html_raw', 'text_html_cleaned', 'text_cleaned', 'form'],
 
290
  AVAILABLE_FEATURES={sector: datasets.Features({feature:(FEATURES[feature] if feature in FEATURES else datasets.Sequence(datasets.Value("string"))) for feature in FEATURES_IN_SECTOR[sector]}) for sector in SECTORS}
291
 
292
  SECTOR_DESCRIPTIONS={
293
+ '0':"Consolidated acts ",
294
+ '1':"Treaties",
295
+ '2':"International agreements",
296
+ '3':"Legislation",
297
+ '4':"Complementary legislation",
298
+ '5':"Preparatory acts and working documents",
299
+ '6':"Case-law",
300
+ '7':"National transposition measures",
301
+ '8':"References to national case-law concerning EU law",
302
+ '9':"Parliamentary questions",
303
+ 'C':"Other documents published in the Official Journal C series",
304
+ 'E':"EFTA documents",
305
  }
306
 
307
 
 
356
  for lang in AVAILABLE_LANGUAGES for sect in SECTORS
357
  ]
358
 
359
+ #DEFAULT_CONFIG_NAME = "3.DE" # It's not mandatory to have a default configuration. Just use one if it make sense.
360
 
361
  def _info(self):
362
  # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
 
387
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
388
  urls = {'text': self.config.text_data_url,
389
  'meta': self.config.meta_data_url} #_URLS[self.config.name]
390
+ try:
391
+ data_dir = dl_manager.download_and_extract(urls)
392
+ except FileNotFoundError:
393
+ raise Exception("""The demanded Files weren't found.
394
+ It could be that the demanded sector isn't yet available in your language of choice""")
395
  return [
396
  datasets.SplitGenerator(
397
  name=datasets.Split.TRAIN,
 
421
  yield i, sample
422
 
423
 
 
 
424
  if __name__ == '__main__':
425
  import datasets as ds
426
  import sys