Datasets:
Tasks:
Text Classification
Sub-tasks:
multi-label-classification
Languages:
English
Size:
10K<n<100K
ArXiv:
License:
Delete loading script
Browse files- ecthr_cases.py +0 -199
ecthr_cases.py
DELETED
@@ -1,199 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
-
#
|
4 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
# you may not use this file except in compliance with the License.
|
6 |
-
# You may obtain a copy of the License at
|
7 |
-
#
|
8 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
-
#
|
10 |
-
# Unless required by applicable law or agreed to in writing, software
|
11 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
-
# See the License for the specific language governing permissions and
|
14 |
-
# limitations under the License.
|
15 |
-
"""The ECtHR Cases dataset is designed for experimentation of neural judgment prediction and rationale extraction considering ECtHR cases."""
|
16 |
-
|
17 |
-
|
18 |
-
import json
|
19 |
-
import os
|
20 |
-
|
21 |
-
import datasets
|
22 |
-
|
23 |
-
|
24 |
-
_CITATION = """\
|
25 |
-
@InProceedings{chalkidis-et-al-2021-ecthr,
|
26 |
-
title = "Paragraph-level Rationale Extraction through Regularization: A case study on European Court of Human Rights Cases",
|
27 |
-
author = "Chalkidis, Ilias and Fergadiotis, Manos and Tsarapatsanis, Dimitrios and Aletras, Nikolaos and Androutsopoulos, Ion and Malakasiotis, Prodromos",
|
28 |
-
booktitle = "Proceedings of the Annual Conference of the North American Chapter of the Association for Computational Linguistics",
|
29 |
-
year = "2021",
|
30 |
-
address = "Mexico City, Mexico",
|
31 |
-
publisher = "Association for Computational Linguistics"
|
32 |
-
}
|
33 |
-
"""
|
34 |
-
|
35 |
-
_DESCRIPTION = """\
|
36 |
-
The ECtHR Cases dataset is designed for experimentation of neural judgment prediction and rationale extraction considering ECtHR cases.
|
37 |
-
"""
|
38 |
-
|
39 |
-
_HOMEPAGE = "http://archive.org/details/ECtHR-NAACL2021/"
|
40 |
-
|
41 |
-
_LICENSE = "CC BY-NC-SA (Creative Commons / Attribution-NonCommercial-ShareAlike)"
|
42 |
-
|
43 |
-
_URLs = {
|
44 |
-
"alleged-violation-prediction": "http://archive.org/download/ECtHR-NAACL2021/dataset.zip",
|
45 |
-
"violation-prediction": "http://archive.org/download/ECtHR-NAACL2021/dataset.zip",
|
46 |
-
}
|
47 |
-
|
48 |
-
ARTICLES = {
|
49 |
-
"2": "Right to life",
|
50 |
-
"3": "Prohibition of torture",
|
51 |
-
"4": "Prohibition of slavery and forced labour",
|
52 |
-
"5": "Right to liberty and security",
|
53 |
-
"6": "Right to a fair trial",
|
54 |
-
"7": "No punishment without law",
|
55 |
-
"8": "Right to respect for private and family life",
|
56 |
-
"9": "Freedom of thought, conscience and religion",
|
57 |
-
"10": "Freedom of expression",
|
58 |
-
"11": "Freedom of assembly and association",
|
59 |
-
"12": "Right to marry",
|
60 |
-
"13": "Right to an effective remedy",
|
61 |
-
"14": "Prohibition of discrimination",
|
62 |
-
"15": "Derogation in time of emergency",
|
63 |
-
"16": "Restrictions on political activity of aliens",
|
64 |
-
"17": "Prohibition of abuse of rights",
|
65 |
-
"18": "Limitation on use of restrictions on rights",
|
66 |
-
"34": "Individual applications",
|
67 |
-
"38": "Examination of the case",
|
68 |
-
"39": "Friendly settlements",
|
69 |
-
"46": "Binding force and execution of judgments",
|
70 |
-
"P1-1": "Protection of property",
|
71 |
-
"P1-2": "Right to education",
|
72 |
-
"P1-3": "Right to free elections",
|
73 |
-
"P3-1": "Right to free elections",
|
74 |
-
"P4-1": "Prohibition of imprisonment for debt",
|
75 |
-
"P4-2": "Freedom of movement",
|
76 |
-
"P4-3": "Prohibition of expulsion of nationals",
|
77 |
-
"P4-4": "Prohibition of collective expulsion of aliens",
|
78 |
-
"P6-1": "Abolition of the death penalty",
|
79 |
-
"P6-2": "Death penalty in time of war",
|
80 |
-
"P6-3": "Prohibition of derogations",
|
81 |
-
"P7-1": "Procedural safeguards relating to expulsion of aliens",
|
82 |
-
"P7-2": "Right of appeal in criminal matters",
|
83 |
-
"P7-3": "Compensation for wrongful conviction",
|
84 |
-
"P7-4": "Right not to be tried or punished twice",
|
85 |
-
"P7-5": "Equality between spouses",
|
86 |
-
"P12-1": "General prohibition of discrimination",
|
87 |
-
"P13-1": "Abolition of the death penalty",
|
88 |
-
"P13-2": "Prohibition of derogations",
|
89 |
-
"P13-3": "Prohibition of reservations",
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
94 |
-
class EcthrCases(datasets.GeneratorBasedBuilder):
|
95 |
-
"""The ECtHR Cases dataset is designed for experimentation of neural judgment prediction and rationale extraction considering ECtHR cases."""
|
96 |
-
|
97 |
-
VERSION = datasets.Version("1.1.0")
|
98 |
-
|
99 |
-
BUILDER_CONFIGS = [
|
100 |
-
datasets.BuilderConfig(
|
101 |
-
name="alleged-violation-prediction",
|
102 |
-
version=VERSION,
|
103 |
-
description="This part of the dataset covers alleged violation prediction",
|
104 |
-
),
|
105 |
-
datasets.BuilderConfig(
|
106 |
-
name="violation-prediction",
|
107 |
-
version=VERSION,
|
108 |
-
description="This part of the dataset covers violation prediction",
|
109 |
-
),
|
110 |
-
]
|
111 |
-
|
112 |
-
DEFAULT_CONFIG_NAME = "alleged-violation-prediction"
|
113 |
-
|
114 |
-
def _info(self):
|
115 |
-
if self.config.name == "alleged-violation-prediction":
|
116 |
-
features = datasets.Features(
|
117 |
-
{
|
118 |
-
"facts": datasets.features.Sequence(datasets.Value("string")),
|
119 |
-
"labels": datasets.features.Sequence(datasets.Value("string")),
|
120 |
-
"silver_rationales": datasets.features.Sequence(datasets.Value("int32")),
|
121 |
-
"gold_rationales": datasets.features.Sequence(datasets.Value("int32"))
|
122 |
-
# These are the features of your dataset like images, labels ...
|
123 |
-
}
|
124 |
-
)
|
125 |
-
else:
|
126 |
-
features = datasets.Features(
|
127 |
-
{
|
128 |
-
"facts": datasets.features.Sequence(datasets.Value("string")),
|
129 |
-
"labels": datasets.features.Sequence(datasets.Value("string")),
|
130 |
-
"silver_rationales": datasets.features.Sequence(datasets.Value("int32"))
|
131 |
-
# These are the features of your dataset like images, labels ...
|
132 |
-
}
|
133 |
-
)
|
134 |
-
return datasets.DatasetInfo(
|
135 |
-
# This is the description that will appear on the datasets page.
|
136 |
-
description=_DESCRIPTION,
|
137 |
-
# This defines the different columns of the dataset and their types
|
138 |
-
features=features, # Here we define them above because they are different between the two configurations
|
139 |
-
# If there's a common (input, target) tuple from the features,
|
140 |
-
# specify them here. They'll be used if as_supervised=True in
|
141 |
-
# builder.as_dataset.
|
142 |
-
supervised_keys=None,
|
143 |
-
# Homepage of the dataset for documentation
|
144 |
-
homepage=_HOMEPAGE,
|
145 |
-
# License for the dataset if available
|
146 |
-
license=_LICENSE,
|
147 |
-
# Citation for the dataset
|
148 |
-
citation=_CITATION,
|
149 |
-
)
|
150 |
-
|
151 |
-
def _split_generators(self, dl_manager):
|
152 |
-
"""Returns SplitGenerators."""
|
153 |
-
my_urls = _URLs[self.config.name]
|
154 |
-
data_dir = dl_manager.download_and_extract(my_urls)
|
155 |
-
return [
|
156 |
-
datasets.SplitGenerator(
|
157 |
-
name=datasets.Split.TRAIN,
|
158 |
-
# These kwargs will be passed to _generate_examples
|
159 |
-
gen_kwargs={
|
160 |
-
"filepath": os.path.join(data_dir, "train.jsonl"),
|
161 |
-
"split": "train",
|
162 |
-
},
|
163 |
-
),
|
164 |
-
datasets.SplitGenerator(
|
165 |
-
name=datasets.Split.TEST,
|
166 |
-
# These kwargs will be passed to _generate_examples
|
167 |
-
gen_kwargs={"filepath": os.path.join(data_dir, "test.jsonl"), "split": "test"},
|
168 |
-
),
|
169 |
-
datasets.SplitGenerator(
|
170 |
-
name=datasets.Split.VALIDATION,
|
171 |
-
# These kwargs will be passed to _generate_examples
|
172 |
-
gen_kwargs={
|
173 |
-
"filepath": os.path.join(data_dir, "dev.jsonl"),
|
174 |
-
"split": "dev",
|
175 |
-
},
|
176 |
-
),
|
177 |
-
]
|
178 |
-
|
179 |
-
def _generate_examples(
|
180 |
-
self, filepath, split # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
181 |
-
):
|
182 |
-
"""Yields examples as (key, example) tuples."""
|
183 |
-
|
184 |
-
with open(filepath, encoding="utf-8") as f:
|
185 |
-
for id_, row in enumerate(f):
|
186 |
-
data = json.loads(row)
|
187 |
-
if self.config.name == "alleged-violation-prediction":
|
188 |
-
yield id_, {
|
189 |
-
"facts": data["facts"],
|
190 |
-
"labels": data["allegedly_violated_articles"],
|
191 |
-
"silver_rationales": data["silver_rationales"],
|
192 |
-
"gold_rationales": data["gold_rationales"],
|
193 |
-
}
|
194 |
-
else:
|
195 |
-
yield id_, {
|
196 |
-
"facts": data["facts"],
|
197 |
-
"labels": data["violated_articles"],
|
198 |
-
"silver_rationales": data["silver_rationales"],
|
199 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|