add repo_data_only flag

#1
by dlwh - opened
Files changed (1) hide show
  1. Multi_Legal_Pile.py +40 -37
Multi_Legal_Pile.py CHANGED
@@ -193,7 +193,7 @@ _JURISDICTONS = ["Austria", "Belgium", "Bulgaria", "Croatia", "Czechia", "Denmar
193
  class MultiLegalPileConfig(datasets.BuilderConfig):
194
  """BuilderConfig for MultiLegalPile."""
195
 
196
- def __init__(self, name: str, **kwargs):
197
  """BuilderConfig for MultiLegalPile.
198
  Args:
199
  name: combination of language and type with _
@@ -205,10 +205,12 @@ class MultiLegalPileConfig(datasets.BuilderConfig):
205
  self.name = name
206
  self.language = name.split("_")[0]
207
  self.type = name.split("_")[1]
 
208
 
209
 
210
  class MultiLegalPile(datasets.GeneratorBasedBuilder):
211
  """MultiLegalPile: A Corpus Covering Large-Scale Multilingual Legal Data"""
 
212
 
213
  BUILDER_CONFIGS = [MultiLegalPileConfig(f"{language}_{type}")
214
  for type in _TYPES + ["all"]
@@ -249,47 +251,48 @@ class MultiLegalPile(datasets.GeneratorBasedBuilder):
249
  info["filepath"] = download_url("joelito/Multi_Legal_Pile", f"{language}/{type}/{data_name}")
250
  data_infos.append(info.copy())
251
 
252
- # add eurlex_resources data
253
- info["jurisdiction"] = "EU"
254
- if type == 'caselaw':
255
- info["filepath"] = download_url("joelito/eurlex_resources", f"{language}/caselaw")
256
- data_infos.append(info.copy())
257
- elif type == 'legislation':
258
- for resource_type in ["decision", "directive", "regulation", "recommendation", "proposal"]:
259
- info["filepath"] = download_url("joelito/eurlex_resources", f"{language}/{resource_type}")
260
  data_infos.append(info.copy())
261
- elif type == 'contracts':
262
- # international agreements
263
- info["filepath"] = download_url("joelito/eurlex_resources", f"{language}/intagr")
264
- data_infos.append(info.copy())
265
-
266
- # add mc4_legal data
267
- if type == 'other':
268
- info["jurisdiction"] = "N/A"
269
- if language in ["de", "en", "es"]: # here we need to chunk because the files are too large
270
- for idx in [0, 1]:
271
- info["filepath"] = download_url("joelito/mc4_legal", f"{language}_{idx}")
272
  data_infos.append(info.copy())
273
- elif language in ["hr"]:
274
- pass # nothing there for Croatian
275
- else:
276
- info["filepath"] = download_url("joelito/mc4_legal", f"{language}")
277
  data_infos.append(info.copy())
278
 
279
- # add pile-of-law data
280
- if language == 'en':
281
- info["jurisdiction"] = "US"
282
- for name, train_val_files in _PILE_OF_LAW_NAMES[type].items():
283
- if name == 'canadian_decisions':
284
- info["jurisdiction"] = "Canada"
285
- elif name in ['echr']:
286
- info["jurisdiction"] = "EU"
287
- elif name in ['constitutions']:
288
- info["jurisdiction"] = "N/A"
289
- for split in ["train", "validation"]:
290
- for file_name in train_val_files[split]:
291
- info["filepath"] = download_url("pile-of-law/pile-of-law", file_name)
292
  data_infos.append(info.copy())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
 
294
  return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"data_infos": data_infos})]
295
 
 
193
  class MultiLegalPileConfig(datasets.BuilderConfig):
194
  """BuilderConfig for MultiLegalPile."""
195
 
196
+ def __init__(self, name: str, repo_data_only=False, **kwargs):
197
  """BuilderConfig for MultiLegalPile.
198
  Args:
199
  name: combination of language and type with _
 
205
  self.name = name
206
  self.language = name.split("_")[0]
207
  self.type = name.split("_")[1]
208
+ self.repo_data_only = repo_data_only
209
 
210
 
211
  class MultiLegalPile(datasets.GeneratorBasedBuilder):
212
  """MultiLegalPile: A Corpus Covering Large-Scale Multilingual Legal Data"""
213
+ BUILDER_CONFIG_CLASS = MultiLegalPileConfig
214
 
215
  BUILDER_CONFIGS = [MultiLegalPileConfig(f"{language}_{type}")
216
  for type in _TYPES + ["all"]
 
251
  info["filepath"] = download_url("joelito/Multi_Legal_Pile", f"{language}/{type}/{data_name}")
252
  data_infos.append(info.copy())
253
 
254
+ if not self.config.repo_data_only:
255
+ # add eurlex_resources data
256
+ info["jurisdiction"] = "EU"
257
+ if type == 'caselaw':
258
+ info["filepath"] = download_url("joelito/eurlex_resources", f"{language}/caselaw")
 
 
 
259
  data_infos.append(info.copy())
260
+ elif type == 'legislation':
261
+ for resource_type in ["decision", "directive", "regulation", "recommendation", "proposal"]:
262
+ info["filepath"] = download_url("joelito/eurlex_resources", f"{language}/{resource_type}")
 
 
 
 
 
 
 
 
263
  data_infos.append(info.copy())
264
+ elif type == 'contracts':
265
+ # international agreements
266
+ info["filepath"] = download_url("joelito/eurlex_resources", f"{language}/intagr")
 
267
  data_infos.append(info.copy())
268
 
269
+ # add mc4_legal data
270
+ if type == 'other':
271
+ info["jurisdiction"] = "N/A"
272
+ if language in ["de", "en", "es"]: # here we need to chunk because the files are too large
273
+ for idx in [0, 1]:
274
+ info["filepath"] = download_url("joelito/mc4_legal", f"{language}_{idx}")
 
 
 
 
 
 
 
275
  data_infos.append(info.copy())
276
+ elif language in ["hr"]:
277
+ pass # nothing there for Croatian
278
+ else:
279
+ info["filepath"] = download_url("joelito/mc4_legal", f"{language}")
280
+ data_infos.append(info.copy())
281
+
282
+ # add pile-of-law data
283
+ if language == 'en':
284
+ info["jurisdiction"] = "US"
285
+ for name, train_val_files in _PILE_OF_LAW_NAMES[type].items():
286
+ if name == 'canadian_decisions':
287
+ info["jurisdiction"] = "Canada"
288
+ elif name in ['echr']:
289
+ info["jurisdiction"] = "EU"
290
+ elif name in ['constitutions']:
291
+ info["jurisdiction"] = "N/A"
292
+ for split in ["train", "validation"]:
293
+ for file_name in train_val_files[split]:
294
+ info["filepath"] = download_url("pile-of-law/pile-of-law", file_name)
295
+ data_infos.append(info.copy())
296
 
297
  return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"data_infos": data_infos})]
298