Commit
•
8eeb3b7
1
Parent(s):
3af26b9
Add dataset script
Browse files- legal_contracts.py +77 -0
legal_contracts.py
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"""Legal Contracts dataset."""
|
16 |
+
|
17 |
+
import datasets
|
18 |
+
|
19 |
+
|
20 |
+
# TODO: Add BibTeX citation
|
21 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
22 |
+
_CITATION = """\
|
23 |
+
@InProceedings{huggingface:dataset,
|
24 |
+
title = {A great new dataset},
|
25 |
+
author={huggingface, Inc.
|
26 |
+
},
|
27 |
+
year={2020}
|
28 |
+
}
|
29 |
+
"""
|
30 |
+
|
31 |
+
# TODO: Add description of the dataset here
|
32 |
+
# You can copy an official description
|
33 |
+
_DESCRIPTION = """\
|
34 |
+
This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
|
35 |
+
"""
|
36 |
+
|
37 |
+
# TODO: Add a link to an official homepage for the dataset here
|
38 |
+
_HOMEPAGE = "https://drive.google.com/file/d/1of37X0hAhECQ3BN_004D8gm6V88tgZaB/view?usp=sharing"
|
39 |
+
|
40 |
+
# TODO: Add the licence for the dataset here if you can find it
|
41 |
+
_LICENSE = ""
|
42 |
+
|
43 |
+
_URL = "https://huggingface.co/datasets/albertvillanova/legal_contracts/resolve/main/contracts.tar.gz"
|
44 |
+
|
45 |
+
|
46 |
+
class LegalContracts(datasets.GeneratorBasedBuilder):
|
47 |
+
"""Legal Contracts dataset."""
|
48 |
+
|
49 |
+
VERSION = datasets.Version("1.0.0")
|
50 |
+
|
51 |
+
def _info(self):
|
52 |
+
return datasets.DatasetInfo(
|
53 |
+
description=_DESCRIPTION,
|
54 |
+
features=datasets.Features({"text": datasets.Value("string")}),
|
55 |
+
supervised_keys=None,
|
56 |
+
homepage=_HOMEPAGE,
|
57 |
+
license=_LICENSE,
|
58 |
+
citation=_CITATION,
|
59 |
+
)
|
60 |
+
|
61 |
+
def _split_generators(self, dl_manager):
|
62 |
+
archive = dl_manager.download(_URL)
|
63 |
+
return [
|
64 |
+
datasets.SplitGenerator(
|
65 |
+
name=datasets.Split.TRAIN,
|
66 |
+
gen_kwargs={
|
67 |
+
"iter_archive": dl_manager.iter_archive(archive),
|
68 |
+
},
|
69 |
+
),
|
70 |
+
]
|
71 |
+
|
72 |
+
def _generate_examples(self, iter_archive):
|
73 |
+
for key, (path, f) in enumerate(iter_archive):
|
74 |
+
if path.endswith(".txt"):
|
75 |
+
yield key, {
|
76 |
+
"text": f.read().decode("utf-8"),
|
77 |
+
}
|