Datasets:
ArXiv:
legal glue py - multieurlex fix
Browse files- legalglue.py +85 -28
legalglue.py
CHANGED
@@ -8257,9 +8257,9 @@ class LegalGlueConfig(datasets.BuilderConfig):
|
|
8257 |
if language != "all_languages":
|
8258 |
self.languages = [language]
|
8259 |
else:
|
8260 |
-
if self.name
|
8261 |
self.languages = languages if languages is not None else SWISS_LANG
|
8262 |
-
if self.name
|
8263 |
self.languages = languages if languages is not None else MULTI_EURLEX_LANGUAGES
|
8264 |
|
8265 |
|
@@ -8343,7 +8343,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8343 |
language = "pt"
|
8344 |
),
|
8345 |
LegalGlueConfig(
|
8346 |
-
name="
|
8347 |
description=textwrap.dedent(
|
8348 |
"""\
|
8349 |
MultiEURLEX comprises 65k EU laws in 23 official EU languages (some low-ish resource).
|
@@ -8353,6 +8353,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8353 |
"""
|
8354 |
),
|
8355 |
label_classes=EUROVOC_CONCEPTS,
|
|
|
8356 |
multi_label=True,
|
8357 |
homepage="https://github.com/nlpaueb/multi-eurlex",
|
8358 |
data_url="https://zenodo.org/record/5363165/files/multi_eurlex.tar.gz",
|
@@ -8373,7 +8374,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8373 |
)
|
8374 |
),
|
8375 |
LegalGlueConfig(
|
8376 |
-
name="
|
8377 |
description=textwrap.dedent(
|
8378 |
"""
|
8379 |
Swiss-Judgment-Prediction is a multilingual, diachronic dataset of 85K Swiss Federal Supreme Court (FSCS) cases annotated with the respective binarized judgment outcome (approval/dismissal), posing a challenging text classification task. We also provide additional metadata, i.e., the publication year, the legal area and the canton of origin per case, to promote robustness and fairness studies on the critical area of legal NLP.
|
@@ -8381,6 +8382,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8381 |
),
|
8382 |
label_classes=[0, 1],
|
8383 |
multi_label=False,
|
|
|
8384 |
data_url="https://zenodo.org/record/5529712/files/",
|
8385 |
data_files=["train.jsonl", "val.jsonl", "test.jsonl"],
|
8386 |
homepage="https://github.com/JoelNiklaus/SwissCourtRulingCorpus",
|
@@ -8396,30 +8398,85 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8396 |
}"""
|
8397 |
),
|
8398 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8399 |
]
|
8400 |
|
8401 |
def _info(self):
|
8402 |
if self.config.name == "german_ler":
|
8403 |
-
features =
|
8404 |
-
|
8405 |
-
|
8406 |
-
|
8407 |
-
datasets.
|
8408 |
-
|
|
|
|
|
8409 |
)
|
8410 |
-
|
8411 |
-
|
8412 |
elif self.config.name == "lener_br":
|
8413 |
-
features =
|
8414 |
-
|
8415 |
-
|
8416 |
-
|
8417 |
-
datasets.
|
8418 |
-
|
8419 |
-
|
8420 |
-
|
8421 |
-
|
8422 |
-
|
|
|
|
|
8423 |
features = datasets.Features(
|
8424 |
{
|
8425 |
"id": datasets.Value("int32"),
|
@@ -8432,7 +8489,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8432 |
"legal area": datasets.Value("string"),
|
8433 |
}
|
8434 |
)
|
8435 |
-
elif self.config.name
|
8436 |
if self.config.language == "all_languages":
|
8437 |
features = datasets.Features(
|
8438 |
{
|
@@ -8457,7 +8514,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8457 |
)
|
8458 |
return datasets.DatasetInfo(
|
8459 |
description=self.config.description,
|
8460 |
-
features=
|
8461 |
homepage=self.config.homepage,
|
8462 |
citation=self.config.citation,
|
8463 |
)
|
@@ -8507,7 +8564,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8507 |
},
|
8508 |
),
|
8509 |
]
|
8510 |
-
elif self.config.name
|
8511 |
urls_to_download = {
|
8512 |
"train": self.config.data_url + "train.jsonl",
|
8513 |
"test": self.config.data_url + "test.jsonl",
|
@@ -8531,7 +8588,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8531 |
gen_kwargs={"filepath": data_dir["val"], "split": "dev"},
|
8532 |
),
|
8533 |
]
|
8534 |
-
elif self.config.name
|
8535 |
data_dir = dl_manager.download_and_extract(self.config.data_url)
|
8536 |
return [
|
8537 |
datasets.SplitGenerator(
|
@@ -8610,7 +8667,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8610 |
"ner_tags": ner_tags,
|
8611 |
}
|
8612 |
|
8613 |
-
elif self.config.name
|
8614 |
if self.config.language == "all_languages":
|
8615 |
with open(filepath, encoding="utf-8") as f:
|
8616 |
for id_, row in enumerate(f):
|
@@ -8641,7 +8698,7 @@ class LegalGLUE(datasets.GeneratorBasedBuilder):
|
|
8641 |
"legal area": data["legal area"],
|
8642 |
}
|
8643 |
|
8644 |
-
elif self.config.name
|
8645 |
if self.config.language == "all_languages":
|
8646 |
with open(filepath, encoding="utf-8") as f:
|
8647 |
for id_, row in enumerate(f):
|
|
|
8257 |
if language != "all_languages":
|
8258 |
self.languages = [language]
|
8259 |
else:
|
8260 |
+
if "swissJudgmentPrediction" in self.name:
|
8261 |
self.languages = languages if languages is not None else SWISS_LANG
|
8262 |
+
if "multi_eurlex" in self.name:
|
8263 |
self.languages = languages if languages is not None else MULTI_EURLEX_LANGUAGES
|
8264 |
|
8265 |
|
|
|
8343 |
language = "pt"
|
8344 |
),
|
8345 |
LegalGlueConfig(
|
8346 |
+
name="multi_eurlex_all_languages",
|
8347 |
description=textwrap.dedent(
|
8348 |
"""\
|
8349 |
MultiEURLEX comprises 65k EU laws in 23 official EU languages (some low-ish resource).
|
|
|
8353 |
"""
|
8354 |
),
|
8355 |
label_classes=EUROVOC_CONCEPTS,
|
8356 |
+
language="all_languages",
|
8357 |
multi_label=True,
|
8358 |
homepage="https://github.com/nlpaueb/multi-eurlex",
|
8359 |
data_url="https://zenodo.org/record/5363165/files/multi_eurlex.tar.gz",
|
|
|
8374 |
)
|
8375 |
),
|
8376 |
LegalGlueConfig(
|
8377 |
+
name="swissJudgmentPrediction_all_languages",
|
8378 |
description=textwrap.dedent(
|
8379 |
"""
|
8380 |
Swiss-Judgment-Prediction is a multilingual, diachronic dataset of 85K Swiss Federal Supreme Court (FSCS) cases annotated with the respective binarized judgment outcome (approval/dismissal), posing a challenging text classification task. We also provide additional metadata, i.e., the publication year, the legal area and the canton of origin per case, to promote robustness and fairness studies on the critical area of legal NLP.
|
|
|
8382 |
),
|
8383 |
label_classes=[0, 1],
|
8384 |
multi_label=False,
|
8385 |
+
language="all_languages",
|
8386 |
data_url="https://zenodo.org/record/5529712/files/",
|
8387 |
data_files=["train.jsonl", "val.jsonl", "test.jsonl"],
|
8388 |
homepage="https://github.com/JoelNiklaus/SwissCourtRulingCorpus",
|
|
|
8398 |
}"""
|
8399 |
),
|
8400 |
),
|
8401 |
+
] + [
|
8402 |
+
LegalGlueConfig(
|
8403 |
+
name="multi_eurlex" + "_" + lang,
|
8404 |
+
description=f"Plain text import of MultiEURLEX for the {lang} language",
|
8405 |
+
label_classes=EUROVOC_CONCEPTS,
|
8406 |
+
language=lang,
|
8407 |
+
multi_label=True,
|
8408 |
+
homepage="https://github.com/nlpaueb/multi-eurlex",
|
8409 |
+
data_url="https://zenodo.org/record/5363165/files/multi_eurlex.tar.gz",
|
8410 |
+
data_files=["train.jsonl", "test.jsonl", "dev.jsonl"],
|
8411 |
+
citation=textwrap.dedent("""\
|
8412 |
+
@InProceedings{chalkidis-etal-2021-multieurlex,
|
8413 |
+
author = {Chalkidis, Ilias
|
8414 |
+
and Fergadiotis, Manos
|
8415 |
+
and Androutsopoulos, Ion},
|
8416 |
+
title = {MultiEURLEX -- A multi-lingual and multi-label legal document
|
8417 |
+
classification dataset for zero-shot cross-lingual transfer},
|
8418 |
+
booktitle = {Proceedings of the 2021 Conference on Empirical Methods
|
8419 |
+
in Natural Language Processing},
|
8420 |
+
year = {2021},
|
8421 |
+
publisher = {Association for Computational Linguistics},
|
8422 |
+
location = {Punta Cana, Dominican Republic},
|
8423 |
+
}"""
|
8424 |
+
)
|
8425 |
+
)for lang in MULTI_EURLEX_LANGUAGES
|
8426 |
+
] + [
|
8427 |
+
LegalGlueConfig(
|
8428 |
+
name="swissJudgmentPrediction" + "_"+ lang,
|
8429 |
+
description=textwrap.dedent(
|
8430 |
+
"""
|
8431 |
+
Swiss-Judgment-Prediction is a multilingual, diachronic dataset of 85K Swiss Federal Supreme Court (FSCS) cases annotated with the respective binarized judgment outcome (approval/dismissal), posing a challenging text classification task. We also provide additional metadata, i.e., the publication year, the legal area and the canton of origin per case, to promote robustness and fairness studies on the critical area of legal NLP.
|
8432 |
+
"""
|
8433 |
+
),
|
8434 |
+
label_classes=[0, 1],
|
8435 |
+
language=lang,
|
8436 |
+
multi_label=False,
|
8437 |
+
data_url="https://zenodo.org/record/5529712/files/",
|
8438 |
+
data_files=["train.jsonl", "val.jsonl", "test.jsonl"],
|
8439 |
+
homepage="https://github.com/JoelNiklaus/SwissCourtRulingCorpus",
|
8440 |
+
citation=textwrap.dedent("""\
|
8441 |
+
@InProceedings{niklaus-etal-2021-swiss,
|
8442 |
+
author = {Niklaus, Joel
|
8443 |
+
and Chalkidis, Ilias
|
8444 |
+
and Stürmer, Matthias},
|
8445 |
+
title = {Swiss-Court-Predict: A Multilingual Legal Judgment Prediction Benchmark},
|
8446 |
+
booktitle = {Proceedings of the 2021 Natural Legal Language Processing Workshop},
|
8447 |
+
year = {2021},
|
8448 |
+
location = {Punta Cana, Dominican Republic},
|
8449 |
+
}"""
|
8450 |
+
),
|
8451 |
+
)for lang in SWISS_LANG
|
8452 |
]
|
8453 |
|
8454 |
def _info(self):
|
8455 |
if self.config.name == "german_ler":
|
8456 |
+
features = datasets.Features(
|
8457 |
+
{
|
8458 |
+
"id": datasets.Value("string"),
|
8459 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
8460 |
+
"ner_tags": datasets.Sequence(
|
8461 |
+
datasets.features.ClassLabel(
|
8462 |
+
names=self.config.label_classes
|
8463 |
+
)
|
8464 |
)
|
8465 |
+
}
|
8466 |
+
)
|
8467 |
elif self.config.name == "lener_br":
|
8468 |
+
features = datasets.Features(
|
8469 |
+
{
|
8470 |
+
"id": datasets.Value("string"),
|
8471 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
8472 |
+
"ner_tags": datasets.Sequence(
|
8473 |
+
datasets.features.ClassLabel(
|
8474 |
+
names=self.config.label_classes
|
8475 |
+
)
|
8476 |
+
)
|
8477 |
+
}
|
8478 |
+
)
|
8479 |
+
elif "swissJudgmentPrediction" in self.config.name:
|
8480 |
features = datasets.Features(
|
8481 |
{
|
8482 |
"id": datasets.Value("int32"),
|
|
|
8489 |
"legal area": datasets.Value("string"),
|
8490 |
}
|
8491 |
)
|
8492 |
+
elif "multi_eurlex" in self.config.name :
|
8493 |
if self.config.language == "all_languages":
|
8494 |
features = datasets.Features(
|
8495 |
{
|
|
|
8514 |
)
|
8515 |
return datasets.DatasetInfo(
|
8516 |
description=self.config.description,
|
8517 |
+
features=features,
|
8518 |
homepage=self.config.homepage,
|
8519 |
citation=self.config.citation,
|
8520 |
)
|
|
|
8564 |
},
|
8565 |
),
|
8566 |
]
|
8567 |
+
elif "swissJudgmentPrediction" in self.config.name:
|
8568 |
urls_to_download = {
|
8569 |
"train": self.config.data_url + "train.jsonl",
|
8570 |
"test": self.config.data_url + "test.jsonl",
|
|
|
8588 |
gen_kwargs={"filepath": data_dir["val"], "split": "dev"},
|
8589 |
),
|
8590 |
]
|
8591 |
+
elif "multi_eurlex" in self.config.name:
|
8592 |
data_dir = dl_manager.download_and_extract(self.config.data_url)
|
8593 |
return [
|
8594 |
datasets.SplitGenerator(
|
|
|
8667 |
"ner_tags": ner_tags,
|
8668 |
}
|
8669 |
|
8670 |
+
elif "swissJudgmentPrediction" in self.config.name:
|
8671 |
if self.config.language == "all_languages":
|
8672 |
with open(filepath, encoding="utf-8") as f:
|
8673 |
for id_, row in enumerate(f):
|
|
|
8698 |
"legal area": data["legal area"],
|
8699 |
}
|
8700 |
|
8701 |
+
elif "multi_eurlex" in self.config.name:
|
8702 |
if self.config.language == "all_languages":
|
8703 |
with open(filepath, encoding="utf-8") as f:
|
8704 |
for id_, row in enumerate(f):
|