jfrenz commited on
Commit
b047cf4
1 Parent(s): 4d385c3

added cuad dataset

Browse files
Files changed (2) hide show
  1. dataset_infos.json +1 -1
  2. legalglue.py +88 -1
dataset_infos.json CHANGED
@@ -1 +1 @@
1
- {"german_ler": {"description": "description", "citation": "@inproceedings{leitner2019fine,\nauthor = {Elena Leitner and Georg Rehm and Julian Moreno-Schneider},\ntitle = {{Fine-grained Named Entity Recognition in Legal Documents}},\nbooktitle = {Semantic Systems. The Power of AI and Knowledge\n Graphs. Proceedings of the 15th International Conference\n (SEMANTiCS 2019)},\nyear = 2019,\neditor = {Maribel Acosta and Philippe Cudr\u00e9-Mauroux and Maria\n Maleshkova and Tassilo Pellegrini and Harald Sack and York\n Sure-Vetter},\nkeywords = {aip},\npublisher = {Springer},\nseries = {Lecture Notes in Computer Science},\nnumber = {11702},\naddress = {Karlsruhe, Germany},\nmonth = 9,\nnote = {10/11 September 2019},\npages = {272--287},\npdf = {https://link.springer.com/content/pdf/10.1007%2F978-3-030-33220-4_20.pdf}}\n", "homepage": "https://github.com/elenanereiss/Legal-Entity-Recognition", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 39, "names": ["B-AN", "B-EUN", "B-GRT", "B-GS", "B-INN", "B-LD", "B-LDS", "B-LIT", "B-MRK", "B-ORG", "B-PER", "B-RR", "B-RS", "B-ST", "B-STR", "B-UN", "B-VO", "B-VS", "B-VT", "I-AN", "I-EUN", "I-GRT", "I-GS", "I-INN", "I-LD", "I-LDS", "I-LIT", "I-MRK", "I-ORG", "I-PER", "I-RR", "I-RS", "I-ST", "I-STR", "I-UN", "I-VO", "I-VS", "I-VT", "O"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "legal_glue", "config_name": "german_ler", "version": {"version_str": "1.1.0", "description": "", "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 38853928, "num_examples": 66723, "dataset_name": "legal_glue"}}, "download_checksums": {"https://raw.githubusercontent.com/elenanereiss/Legal-Entity-Recognition/master/data/dataset_courts.zip": {"num_bytes": 4392913, "checksum": "f0427df5fb8bfdefe5228bc0fa0e75e9cfa782d1a78e32582cce096473c88567"}}, "download_size": 4392913, "post_processing_size": null, "dataset_size": 38853928, "size_in_bytes": 43246841}, "lener_br": {"description": "LeNER-Br is a Portuguese language dataset for named entity recognition\napplied to legal documents. LeNER-Br consists entirely of manually annotated\nlegislation and legal cases texts and contains tags for persons, locations,\ntime entities, organizations, legislation and legal cases.\nTo compose the dataset, 66 legal documents from several Brazilian Courts were\ncollected. Courts of superior and state levels were considered, such as Supremo\nTribunal Federal, Superior Tribunal de Justi\u00e7a, Tribunal de Justi\u00e7a de Minas\nGerais and Tribunal de Contas da Uni\u00e3o. In addition, four legislation documents\nwere collected, such as \"Lei Maria da Penha\", giving a total of 70 documents\n", "citation": "@inproceedings{luz_etal_propor2018,\nauthor = {Pedro H. {Luz de Araujo} and Te'{o}filo E. {de Campos} and\nRenato R. R. {de Oliveira} and Matheus Stauffer and\nSamuel Couto and Paulo Bermejo},\ntitle = {{LeNER-Br}: a Dataset for Named Entity Recognition in {Brazilian} Legal Text},\nbooktitle = {International Conference on the Computational Processing of Portuguese ({PROPOR})},\npublisher = {Springer},\nseries = {Lecture Notes on Computer Science ({LNCS})},\npages = {313--323},\nyear = {2018},\nmonth = {September 24-26},\naddress = {Canela, RS, Brazil},\ndoi = {10.1007/978-3-319-99722-3_32},\nurl = {https://cic.unb.br/~teodecampos/LeNER-Br/},\n}\n", "homepage": "https://cic.unb.br/~teodecampos/LeNER-Br/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 13, "names": ["O", "B-ORGANIZACAO", "I-ORGANIZACAO", "B-PESSOA", "I-PESSOA", "B-TEMPO", "I-TEMPO", "B-LOCAL", "I-LOCAL", "B-LEGISLACAO", "I-LEGISLACAO", "B-JURISPRUDENCIA", "I-JURISPRUDENCIA"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "legal_glue", "config_name": "lener_br", "version": {"version_str": "1.1.0", "description": "", "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 7153474101, "num_examples": 7828, "dataset_name": "legal_glue"}, "test": {"name": "test", "num_bytes": 195782089, "num_examples": 1177, "dataset_name": "legal_glue"}, "validation": {"name": "validation", "num_bytes": 280965196, "num_examples": 1390, "dataset_name": "legal_glue"}}, "download_checksums": {"https://github.com/peluz/lener-br/raw/master/leNER-Br/train/train.conll": {"num_bytes": 2142199, "checksum": "6fdf9066333c84565f9e3d28ee8f0f519336bece69b63f8d78b8de0fe96dcd47"}, "https://github.com/peluz/lener-br/raw/master/leNER-Br/test/test.conll": {"num_bytes": 438441, "checksum": "f90cd26a31afc2d1f132c4473d40c26d2283a98b374025fa5b5985b723dce825"}, "https://github.com/peluz/lener-br/raw/master/leNER-Br/dev/dev.conll": {"num_bytes": 402497, "checksum": "7e350feb828198031e57c21d6aadbf8dac92b19a684e45d7081c6cb491e2063b"}}, "download_size": 2983137, "post_processing_size": null, "dataset_size": 7630221386, "size_in_bytes": 7633204523}}
 
1
+ {"german_ler": {"description": "description", "citation": "@inproceedings{leitner2019fine,\nauthor = {Elena Leitner and Georg Rehm and Julian Moreno-Schneider},\ntitle = {{Fine-grained Named Entity Recognition in Legal Documents}},\nbooktitle = {Semantic Systems. The Power of AI and Knowledge\n Graphs. Proceedings of the 15th International Conference\n (SEMANTiCS 2019)},\nyear = 2019,\neditor = {Maribel Acosta and Philippe Cudr\u00e9-Mauroux and Maria\n Maleshkova and Tassilo Pellegrini and Harald Sack and York\n Sure-Vetter},\nkeywords = {aip},\npublisher = {Springer},\nseries = {Lecture Notes in Computer Science},\nnumber = {11702},\naddress = {Karlsruhe, Germany},\nmonth = 9,\nnote = {10/11 September 2019},\npages = {272--287},\npdf = {https://link.springer.com/content/pdf/10.1007%2F978-3-030-33220-4_20.pdf}}\n", "homepage": "https://github.com/elenanereiss/Legal-Entity-Recognition", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 39, "names": ["B-AN", "B-EUN", "B-GRT", "B-GS", "B-INN", "B-LD", "B-LDS", "B-LIT", "B-MRK", "B-ORG", "B-PER", "B-RR", "B-RS", "B-ST", "B-STR", "B-UN", "B-VO", "B-VS", "B-VT", "I-AN", "I-EUN", "I-GRT", "I-GS", "I-INN", "I-LD", "I-LDS", "I-LIT", "I-MRK", "I-ORG", "I-PER", "I-RR", "I-RS", "I-ST", "I-STR", "I-UN", "I-VO", "I-VS", "I-VT", "O"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "legal_glue", "config_name": "german_ler", "version": {"version_str": "1.1.0", "description": "", "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 38853928, "num_examples": 66723, "dataset_name": "legal_glue"}}, "download_checksums": {"https://raw.githubusercontent.com/elenanereiss/Legal-Entity-Recognition/master/data/dataset_courts.zip": {"num_bytes": 4392913, "checksum": "f0427df5fb8bfdefe5228bc0fa0e75e9cfa782d1a78e32582cce096473c88567"}}, "download_size": 4392913, "post_processing_size": null, "dataset_size": 38853928, "size_in_bytes": 43246841}, "lener_br": {"description": "LeNER-Br is a Portuguese language dataset for named entity recognition\napplied to legal documents. LeNER-Br consists entirely of manually annotated\nlegislation and legal cases texts and contains tags for persons, locations,\ntime entities, organizations, legislation and legal cases.\nTo compose the dataset, 66 legal documents from several Brazilian Courts were\ncollected. Courts of superior and state levels were considered, such as Supremo\nTribunal Federal, Superior Tribunal de Justi\u00e7a, Tribunal de Justi\u00e7a de Minas\nGerais and Tribunal de Contas da Uni\u00e3o. In addition, four legislation documents\nwere collected, such as \"Lei Maria da Penha\", giving a total of 70 documents\n", "citation": "@inproceedings{luz_etal_propor2018,\nauthor = {Pedro H. {Luz de Araujo} and Te'{o}filo E. {de Campos} and\nRenato R. R. {de Oliveira} and Matheus Stauffer and\nSamuel Couto and Paulo Bermejo},\ntitle = {{LeNER-Br}: a Dataset for Named Entity Recognition in {Brazilian} Legal Text},\nbooktitle = {International Conference on the Computational Processing of Portuguese ({PROPOR})},\npublisher = {Springer},\nseries = {Lecture Notes on Computer Science ({LNCS})},\npages = {313--323},\nyear = {2018},\nmonth = {September 24-26},\naddress = {Canela, RS, Brazil},\ndoi = {10.1007/978-3-319-99722-3_32},\nurl = {https://cic.unb.br/~teodecampos/LeNER-Br/},\n}\n", "homepage": "https://cic.unb.br/~teodecampos/LeNER-Br/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 13, "names": ["O", "B-ORGANIZACAO", "I-ORGANIZACAO", "B-PESSOA", "I-PESSOA", "B-TEMPO", "I-TEMPO", "B-LOCAL", "I-LOCAL", "B-LEGISLACAO", "I-LEGISLACAO", "B-JURISPRUDENCIA", "I-JURISPRUDENCIA"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "legal_glue", "config_name": "lener_br", "version": {"version_str": "1.1.0", "description": "", "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 7153474101, "num_examples": 7828, "dataset_name": "legal_glue"}, "test": {"name": "test", "num_bytes": 195782089, "num_examples": 1177, "dataset_name": "legal_glue"}, "validation": {"name": "validation", "num_bytes": 280965196, "num_examples": 1390, "dataset_name": "legal_glue"}}, "download_checksums": {"https://github.com/peluz/lener-br/raw/master/leNER-Br/train/train.conll": {"num_bytes": 2142199, "checksum": "6fdf9066333c84565f9e3d28ee8f0f519336bece69b63f8d78b8de0fe96dcd47"}, "https://github.com/peluz/lener-br/raw/master/leNER-Br/test/test.conll": {"num_bytes": 438441, "checksum": "f90cd26a31afc2d1f132c4473d40c26d2283a98b374025fa5b5985b723dce825"}, "https://github.com/peluz/lener-br/raw/master/leNER-Br/dev/dev.conll": {"num_bytes": 402497, "checksum": "7e350feb828198031e57c21d6aadbf8dac92b19a684e45d7081c6cb491e2063b"}}, "download_size": 2983137, "post_processing_size": null, "dataset_size": 7630221386, "size_in_bytes": 7633204523}, "cuad": {"description": "Contract Understanding Atticus Dataset (CUAD) v1 is a corpus of more than 13,000 labels in 510\ncommercial legal contracts that have been manually labeled to identify 41 categories of important\nclauses that lawyers look for when reviewing contracts in connection with corporate transactions.\n", "citation": "@article{hendrycks2021cuad,\ntitle={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\nauthor={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\njournal={arXiv preprint arXiv:2103.06268},\nyear={2021}\n}\n", "homepage": "https://www.atticusprojectai.org/cuad", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "context": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "answers": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "answer_start": {"dtype": "int32", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "legal_glue", "config_name": "cuad", "version": {"version_str": "1.1.0", "description": "", "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1466037640, "num_examples": 22450, "dataset_name": "legal_glue"}, "test": {"name": "test", "num_bytes": 198543467, "num_examples": 4182, "dataset_name": "legal_glue"}}, "download_checksums": {"https://github.com/TheAtticusProject/cuad/raw/main/data.zip": {"num_bytes": 18309308, "checksum": "f8161d18bea4e9c05e78fa6dda61c19c846fb8087ea969c172753bc2f45b999a"}}, "download_size": 18309308, "post_processing_size": null, "dataset_size": 1664581107, "size_in_bytes": 1682890415}}
legalglue.py CHANGED
@@ -181,6 +181,29 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
181
  url = {https://cic.unb.br/~teodecampos/LeNER-Br/},
182
  }
183
  """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  )
185
  ]
186
 
@@ -205,6 +228,22 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
205
  )
206
  )
207
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  return datasets.DatasetInfo(
209
  description=self.config.description,
210
  features=datasets.Features(features),
@@ -222,7 +261,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
222
  gen_kwargs={
223
  "filepath": self.config.data_files,
224
  "split": "train",
225
- "files": [os.path.join(archive,file) for file in self.config.data_files]#dl_manager.iter_archive(archive),
226
  },
227
  )]
228
  elif self.config.name == "lener_br":
@@ -261,6 +300,28 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
261
  },
262
  ),
263
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
 
265
  # else:
266
  # return [
@@ -324,6 +385,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
324
  "tokens": tokens,
325
  "ner_tags": ner_tags,
326
  }
 
327
  elif self.config.name == "lener_br":
328
  with open(files, encoding="utf-8") as f:
329
  id = 0
@@ -350,3 +412,28 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
350
  "tokens": tokens,
351
  "ner_tags": ner_tags,
352
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  url = {https://cic.unb.br/~teodecampos/LeNER-Br/},
182
  }
183
  """)
184
+ ),
185
+ LegalGlueConfig(
186
+ name="cuad",
187
+ description=textwrap.dedent(
188
+ """\
189
+ Contract Understanding Atticus Dataset (CUAD) v1 is a corpus of more than 13,000 labels in 510
190
+ commercial legal contracts that have been manually labeled to identify 41 categories of important
191
+ clauses that lawyers look for when reviewing contracts in connection with corporate transactions.
192
+ """
193
+ ),
194
+ label_classes=None,
195
+ multi_label=False,
196
+ data_url="https://github.com/TheAtticusProject/cuad/raw/main/data.zip",
197
+ data_files=["train_separate_questions.json", "test.json"],
198
+ homepage="https://www.atticusprojectai.org/cuad",
199
+ citation=textwrap.dedent("""\
200
+ @article{hendrycks2021cuad,
201
+ title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},
202
+ author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},
203
+ journal={arXiv preprint arXiv:2103.06268},
204
+ year={2021}
205
+ }
206
+ """)
207
  )
208
  ]
209
 
 
228
  )
229
  )
230
  }
231
+ elif self.config.name == "cuad":
232
+ features = datasets.Features(
233
+ {
234
+ "id": datasets.Value("string"),
235
+ "title": datasets.Value("string"),
236
+ "context": datasets.Value("string"),
237
+ "question": datasets.Value("string"),
238
+ "answers": datasets.features.Sequence(
239
+ {
240
+ "text": datasets.Value("string"),
241
+ "answer_start": datasets.Value("int32"),
242
+ }
243
+ ),
244
+ }
245
+ )
246
+
247
  return datasets.DatasetInfo(
248
  description=self.config.description,
249
  features=datasets.Features(features),
 
261
  gen_kwargs={
262
  "filepath": self.config.data_files,
263
  "split": "train",
264
+ "files": [os.path.join(archive,file) for file in self.config.data_files],
265
  },
266
  )]
267
  elif self.config.name == "lener_br":
 
300
  },
301
  ),
302
  ]
303
+ elif self.config.name == "cuad":
304
+ archive = dl_manager.download_and_extract(self.config.data_url)
305
+ return [
306
+ datasets.SplitGenerator(
307
+ name=datasets.Split.TRAIN,
308
+ # These kwargs will be passed to _generate_examples
309
+ gen_kwargs={
310
+ "filepath": self.config.data_files ,
311
+ "split": "train",
312
+ "files": os.path.join(archive, self.config.data_files[0])
313
+ },
314
+ ),
315
+ datasets.SplitGenerator(
316
+ name=datasets.Split.TEST,
317
+ # These kwargs will be passed to _generate_examples
318
+ gen_kwargs={
319
+ "filepath": self.config.data_files,
320
+ "split": "test",
321
+ "files": os.path.join(archive, self.config.data_files[1])
322
+ },
323
+ ),
324
+ ]
325
 
326
  # else:
327
  # return [
 
385
  "tokens": tokens,
386
  "ner_tags": ner_tags,
387
  }
388
+
389
  elif self.config.name == "lener_br":
390
  with open(files, encoding="utf-8") as f:
391
  id = 0
 
412
  "tokens": tokens,
413
  "ner_tags": ner_tags,
414
  }
415
+
416
+ elif self.config.name == "cuad":
417
+ with open(files, encoding="utf-8") as f:
418
+ cuad = json.load(f)
419
+ for example in cuad["data"]:
420
+ title = example.get("title", "").strip()
421
+ for paragraph in example["paragraphs"]:
422
+ context = paragraph["context"].strip()
423
+ for qa in paragraph["qas"]:
424
+ question = qa["question"].strip()
425
+ id_ = qa["id"]
426
+
427
+ answer_starts = [answer["answer_start"] for answer in qa["answers"]]
428
+ answers = [answer["text"].strip() for answer in qa["answers"]]
429
+
430
+ yield id_, {
431
+ "title": title,
432
+ "context": context,
433
+ "question": question,
434
+ "id": id_,
435
+ "answers": {
436
+ "answer_start": answer_starts,
437
+ "text": answers,
438
+ },
439
+ }