Datasets:
Tasks:
Text Classification
Formats:
json
Sub-tasks:
entity-linking-classification
Size:
100K - 1M
ArXiv:
DOI:
License:
add doc2doc.py and change folder structure for data files
Browse files- data/test.jsonl.xz +3 -0
- data/train.jsonl.xz +3 -0
- data/validation.jsonl.xz +3 -0
- doc2doc.py +173 -0
data/test.jsonl.xz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6170a45aa5f4be91b3ed6fc3702500106d56bc83a599cce090a5779cb37cf0d2
|
| 3 |
+
size 82048828
|
data/train.jsonl.xz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c73b940460ec6596e0e9640926d67d4857565babb3351efbc811f220765f15cb
|
| 3 |
+
size 228902808
|
data/validation.jsonl.xz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:629277edb40a13e3108aa68a814b92545187e3e6741afc3cfa289c8490d065aa
|
| 3 |
+
size 32592940
|
doc2doc.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Dataset for the doc2doc information retrieval task."""
|
| 15 |
+
|
| 16 |
+
import json
|
| 17 |
+
import lzma
|
| 18 |
+
import os
|
| 19 |
+
|
| 20 |
+
import datasets
|
| 21 |
+
try:
|
| 22 |
+
import lzma as xz
|
| 23 |
+
except ImportError:
|
| 24 |
+
import pylzma as xz
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
# TODO: Add BibTeX citation
|
| 28 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
| 29 |
+
_CITATION = """\
|
| 30 |
+
@InProceedings{huggingface:dataset,
|
| 31 |
+
title = {A great new dataset},
|
| 32 |
+
author={huggingface, Inc.
|
| 33 |
+
},
|
| 34 |
+
year={2020}
|
| 35 |
+
}
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
# You can copy an official description
|
| 39 |
+
_DESCRIPTION = """\
|
| 40 |
+
This dataset contains Swiss federal court decisions for the legal criticality prediction task
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
_URLS = {
|
| 44 |
+
"full": "https://huggingface.co/datasets/rcds/doc2doc/resolve/main/data",
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class doc2doc(datasets.GeneratorBasedBuilder):
|
| 49 |
+
"""This dataset contains court decision for doc2doc information retrieval task."""
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
BUILDER_CONFIGS = [
|
| 53 |
+
datasets.BuilderConfig(name="full", description="This part covers the whole dataset"),
|
| 54 |
+
]
|
| 55 |
+
|
| 56 |
+
DEFAULT_CONFIG_NAME = "full" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
| 57 |
+
|
| 58 |
+
def _info(self):
|
| 59 |
+
if self.config.name == "full" or self.config.name == "origin": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
| 60 |
+
features = datasets.Features(
|
| 61 |
+
{
|
| 62 |
+
"decision_id": datasets.Value("string"),
|
| 63 |
+
"language": datasets.Value("string"),
|
| 64 |
+
"year": datasets.Value("int32"),
|
| 65 |
+
"chamber": datasets.Value("string"),
|
| 66 |
+
"court": datasets.Value("string"),
|
| 67 |
+
"canton": datasets.Value("string"),
|
| 68 |
+
"region": datasets.Value("string"),
|
| 69 |
+
"origin_chamber": datasets.Value("string"),
|
| 70 |
+
"origin_court": datasets.Value("string"),
|
| 71 |
+
"origin_canton": datasets.Value("string"),
|
| 72 |
+
"law_area": datasets.Value("string"),
|
| 73 |
+
"law_sub_area": datasets.Value("string"),
|
| 74 |
+
"cited_rulings": datasets.Value("string"),
|
| 75 |
+
"laws": datasets.Value("string"),
|
| 76 |
+
"facts": datasets.Value("string"),
|
| 77 |
+
"considerations": datasets.Value("string"),
|
| 78 |
+
"rulings": datasets.Value("string"),
|
| 79 |
+
"origin_facts": datasets.Value("string"),
|
| 80 |
+
"origin_considerations": datasets.Value("string"),
|
| 81 |
+
# These are the features of your dataset like images, labels ...
|
| 82 |
+
}
|
| 83 |
+
)
|
| 84 |
+
return datasets.DatasetInfo(
|
| 85 |
+
# This is the description that will appear on the datasets page.
|
| 86 |
+
description=_DESCRIPTION,
|
| 87 |
+
# This defines the different columns of the dataset and their types
|
| 88 |
+
features=features, # Here we define them above because they are different between the two configurations
|
| 89 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
| 90 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
| 91 |
+
# supervised_keys=("sentence", "label"),
|
| 92 |
+
# Homepage of the dataset for documentation
|
| 93 |
+
# homepage=_HOMEPAGE,
|
| 94 |
+
# License for the dataset if available
|
| 95 |
+
# license=_LICENSE,
|
| 96 |
+
# Citation for the dataset
|
| 97 |
+
# citation=_CITATION,
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
def _split_generators(self, dl_manager):
|
| 101 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
| 102 |
+
|
| 103 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
| 104 |
+
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
| 105 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 106 |
+
urls = _URLS[self.config.name]
|
| 107 |
+
filepath_train = dl_manager.download(os.path.join(urls, "train.jsonl.xz"))
|
| 108 |
+
filepath_validation = dl_manager.download(os.path.join(urls, "validation.jsonl.xz"))
|
| 109 |
+
filepath_test = dl_manager.download(os.path.join(urls, "test.jsonl.xz"))
|
| 110 |
+
|
| 111 |
+
return [
|
| 112 |
+
datasets.SplitGenerator(
|
| 113 |
+
name=datasets.Split.TRAIN,
|
| 114 |
+
# These kwargs will be passed to _generate_examples
|
| 115 |
+
gen_kwargs={
|
| 116 |
+
"filepath": filepath_train,
|
| 117 |
+
"split": "train",
|
| 118 |
+
},
|
| 119 |
+
),
|
| 120 |
+
datasets.SplitGenerator(
|
| 121 |
+
name=datasets.Split.VALIDATION,
|
| 122 |
+
# These kwargs will be passed to _generate_examples
|
| 123 |
+
gen_kwargs={
|
| 124 |
+
"filepath": filepath_validation,
|
| 125 |
+
"split": "validation",
|
| 126 |
+
},
|
| 127 |
+
),
|
| 128 |
+
datasets.SplitGenerator(
|
| 129 |
+
name=datasets.Split.TEST,
|
| 130 |
+
# These kwargs will be passed to _generate_examples
|
| 131 |
+
gen_kwargs={
|
| 132 |
+
"filepath": filepath_test,
|
| 133 |
+
"split": "test"
|
| 134 |
+
},
|
| 135 |
+
)
|
| 136 |
+
]
|
| 137 |
+
|
| 138 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 139 |
+
def _generate_examples(self, filepath, split):
|
| 140 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 141 |
+
line_counter = 0
|
| 142 |
+
try:
|
| 143 |
+
with xz.open(open(filepath, "rb"), "rt", encoding="utf-8") as f:
|
| 144 |
+
for id, line in enumerate(f):
|
| 145 |
+
line_counter += 1
|
| 146 |
+
if line:
|
| 147 |
+
data = json.loads(line)
|
| 148 |
+
if self.config.name == "full" or self.config.name == "origin":
|
| 149 |
+
yield id, {
|
| 150 |
+
"decision_id": data["decision_id"],
|
| 151 |
+
"language": data["language"],
|
| 152 |
+
"year": data["year"],
|
| 153 |
+
"chamber": data["chamber"],
|
| 154 |
+
"court": data["court"],
|
| 155 |
+
"canton": data["canton"],
|
| 156 |
+
"region": data["region"],
|
| 157 |
+
"origin_chamber": data["origin_chamber"],
|
| 158 |
+
"origin_court": data["origin_court"],
|
| 159 |
+
"origin_canton": data["origin_canton"],
|
| 160 |
+
"law_area": data["law_area"],
|
| 161 |
+
"law_sub_area": data["law_sub_area"],
|
| 162 |
+
"cited_rulings": data["cited_rulings"],
|
| 163 |
+
"laws": data["laws"],
|
| 164 |
+
"facts": data["facts"],
|
| 165 |
+
"considerations": data["considerations"],
|
| 166 |
+
"rulings": data["rulings"],
|
| 167 |
+
"origin_facts": data["origin_facts"],
|
| 168 |
+
"origin_considerations": data["origin_considerations"]
|
| 169 |
+
}
|
| 170 |
+
except lzma.LZMAError as e:
|
| 171 |
+
print(split, e)
|
| 172 |
+
if line_counter == 0:
|
| 173 |
+
raise e
|