Datasets:
rcds
/

ArXiv:
Tags:
legal
License:
ramonachristen commited on
Commit
ba4e7ed
1 Parent(s): 5a49f7c

Update MultiLegalNeg.py

Browse files
Files changed (1) hide show
  1. MultiLegalNeg.py +14 -37
MultiLegalNeg.py CHANGED
@@ -28,6 +28,9 @@ _URL = {
28
  _LANGUAGES = [
29
  "de", "fr", "it", "swiss", "en"
30
  ]
 
 
 
31
 
32
 
33
  class MultiLegalNegConfig(datasets.BuilderConfig):
@@ -36,14 +39,16 @@ class MultiLegalNegConfig(datasets.BuilderConfig):
36
  super( MultiLegalNegConfig, self).__init__(**kwargs)
37
  self.name = name
38
  self.language = name.split("_")[0]
 
39
 
40
  class MultiLegalNeg(datasets.GeneratorBasedBuilder):
41
 
42
  BUILDER_CONFIG_CLASS = MultiLegalNegConfig
43
 
44
  BUILDER_CONFIGS = [
45
- MultiLegalNegConfig(f"{language}")
46
  for language in _LANGUAGES + ['all']
 
47
  ]
48
  DEFAULT_CONFIG_NAME = 'all_all'
49
  def _info(self):
@@ -79,45 +84,17 @@ class MultiLegalNeg(datasets.GeneratorBasedBuilder):
79
 
80
  def _split_generators(self, dl_manager):
81
  languages = _LANGUAGES if self.config.language == "all" else [self.config.language]
82
-
83
- data_files = {
84
- "train": [
85
- "data/train/it_train.jsonl.xz",
86
- "data/train/fr_train.jsonl.xz",
87
- "data/train/de_train.jsonl.xz",
88
- "data/train/swiss_train.jsonl.xz",
89
- "data/train/en_sherlock_train.jsonl.xz",
90
- "data/train/en_sfu_train.jsonl.xz",
91
- "data/train/en_bioscope_train.jsonl.xz"
92
- ],
93
- "test": [
94
- "data/test/it_test.jsonl.xz",
95
- "data/test/fr_test.jsonl.xz",
96
- "data/test/de_test.jsonl.xz",
97
- "data/test/swiss_test.jsonl.xz",
98
- "data/test/en_sherlock_test.jsonl.xz",
99
- "data/test/en_sfu_test.jsonl.xz",
100
- "data/test/en_bioscope_test.jsonl.xz"
101
- ],
102
- "validation": [
103
- "data/validation/it_validation.jsonl.xz",
104
- "data/validation/fr_validation.jsonl.xz",
105
- "data/validation/de_validation.jsonl.xz",
106
- "data/validation/swiss_validation.jsonl.xz",
107
- "data/validation/en_sherlock_validation.jsonl.xz",
108
- "data/validation/en_sfu_validation.jsonl.xz",
109
- "data/validation/en_bioscope_validation.jsonl.xz"
110
- ]
111
- }
112
 
113
  split_generators = []
114
- for split in data_files.keys():
115
  filepaths = []
116
- for file_name in data_files[split]:
117
- try:
118
- filepaths.append(dl_manager.download((f'{file_name}')))
119
- except:
120
- break
 
121
  split_generators.append(datasets.SplitGenerator(name=split, gen_kwargs={'filepaths': filepaths}))
122
 
123
  return split_generators
 
28
  _LANGUAGES = [
29
  "de", "fr", "it", "swiss", "en"
30
  ]
31
+ _SUBSETS = [
32
+ "_sherlock", "_sfu", "_bioscope"
33
+ ]
34
 
35
 
36
  class MultiLegalNegConfig(datasets.BuilderConfig):
 
39
  super( MultiLegalNegConfig, self).__init__(**kwargs)
40
  self.name = name
41
  self.language = name.split("_")[0]
42
+ self.subset = name.split("_")[1] if len(name.split("_"))==3 else ""
43
 
44
  class MultiLegalNeg(datasets.GeneratorBasedBuilder):
45
 
46
  BUILDER_CONFIG_CLASS = MultiLegalNegConfig
47
 
48
  BUILDER_CONFIGS = [
49
+ MultiLegalNegConfig(f"{language}_{subset}")
50
  for language in _LANGUAGES + ['all']
51
+ for subset in _SUBSETS + ['all']
52
  ]
53
  DEFAULT_CONFIG_NAME = 'all_all'
54
  def _info(self):
 
84
 
85
  def _split_generators(self, dl_manager):
86
  languages = _LANGUAGES if self.config.language == "all" else [self.config.language]
87
+ subsets = _SUBSETS if self.config.subset == "all" else [self.config.subset]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
  split_generators = []
90
+ for split in [datasets.Split.TRAIN, datasets.Split.TEST, datasets.Split.TRAIN, datasets.Split.VALIDATION]:
91
  filepaths = []
92
+ for language in languages:
93
+ for subset in subsets:
94
+ try:
95
+ filepaths.append(dl_manager.download((f'data/{split}/{language}{subset}_{split}.jsonl.xz')))
96
+ except:
97
+ break
98
  split_generators.append(datasets.SplitGenerator(name=split, gen_kwargs={'filepaths': filepaths}))
99
 
100
  return split_generators