albertvillanova HF staff commited on
Commit
b191005
1 Parent(s): f67fbc7

Delete loading script

Browse files
Files changed (1) hide show
  1. eu_regulatory_ir.py +0 -149
eu_regulatory_ir.py DELETED
@@ -1,149 +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
- """EURegIR: Regulatory Compliance IR (EU/UK)"""
16
-
17
-
18
- import json
19
- import os
20
-
21
- import datasets
22
-
23
-
24
- _CITATION = """\
25
- @inproceedings{chalkidis-etal-2021-regir,
26
- title = "Regulatory Compliance through Doc2Doc Information Retrieval: A case study in EU/UK legislation where text similarity has limitations",
27
- author = "Chalkidis, Ilias and Fergadiotis, Emmanouil and Manginas, Nikos and Katakalou, Eva, and Malakasiotis, Prodromos",
28
- booktitle = "Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics (EACL 2021)",
29
- year = "2021",
30
- address = "Online",
31
- publisher = "Association for Computational Linguistics",
32
- url = "https://arxiv.org/abs/2101.10726",
33
- }
34
- """
35
-
36
- _DESCRIPTION = """\
37
- EURegIR: Regulatory Compliance IR (EU/UK)
38
- """
39
-
40
- _HOMEPAGE = "https://archive.org/details/eacl2021_regir_dataset"
41
-
42
- _LICENSE = "CC BY-SA (Creative Commons / Attribution-ShareAlike)"
43
-
44
- _URLs = {
45
- "eu2uk": "https://archive.org/download/eacl2021_regir_datasets/eu2uk.zip",
46
- "uk2eu": "https://archive.org/download/eacl2021_regir_datasets/uk2eu.zip",
47
- }
48
-
49
-
50
- class EuRegulatoryIr(datasets.GeneratorBasedBuilder):
51
- """EURegIR: Regulatory Compliance IR (EU/UK)"""
52
-
53
- VERSION = datasets.Version("1.1.0")
54
-
55
- BUILDER_CONFIGS = [
56
- datasets.BuilderConfig(name="eu2uk", version=VERSION, description="EURegIR: Regulatory Compliance IR (EU2UK)"),
57
- datasets.BuilderConfig(name="uk2eu", version=VERSION, description="EURegIR: Regulatory Compliance IR (UK2EU)"),
58
- ]
59
-
60
- def _info(self):
61
- if self.config.name == "eu2uk":
62
- features = datasets.Features(
63
- {
64
- "document_id": datasets.Value("string"),
65
- "publication_year": datasets.Value("string"),
66
- "text": datasets.Value("string"),
67
- "relevant_documents": datasets.features.Sequence(datasets.Value("string")),
68
- }
69
- )
70
- else:
71
- features = datasets.Features(
72
- {
73
- "document_id": datasets.Value("string"),
74
- "publication_year": datasets.Value("string"),
75
- "text": datasets.Value("string"),
76
- "relevant_documents": datasets.features.Sequence(datasets.Value("string")),
77
- }
78
- )
79
- return datasets.DatasetInfo(
80
- # This is the description that will appear on the datasets page.
81
- description=_DESCRIPTION,
82
- # This defines the different columns of the dataset and their types
83
- features=features, # Here we define them above because they are different between the two configurations
84
- # If there's a common (input, target) tuple from the features,
85
- # specify them here. They'll be used if as_supervised=True in
86
- # builder.as_dataset.
87
- supervised_keys=None,
88
- # Homepage of the dataset for documentation
89
- homepage=_HOMEPAGE,
90
- # License for the dataset if available
91
- license=_LICENSE,
92
- # Citation for the dataset
93
- citation=_CITATION,
94
- )
95
-
96
- def _split_generators(self, dl_manager):
97
- """Returns SplitGenerators."""
98
- my_urls = _URLs[self.config.name]
99
- data_dir = dl_manager.download_and_extract(my_urls)
100
- return [
101
- datasets.SplitGenerator(
102
- name=datasets.Split.TRAIN,
103
- # These kwargs will be passed to _generate_examples
104
- gen_kwargs={
105
- "filepath": os.path.join(data_dir, "train.jsonl"),
106
- "split": "train",
107
- },
108
- ),
109
- datasets.SplitGenerator(
110
- name=datasets.Split.TEST,
111
- # These kwargs will be passed to _generate_examples
112
- gen_kwargs={"filepath": os.path.join(data_dir, "test.jsonl"), "split": "test"},
113
- ),
114
- datasets.SplitGenerator(
115
- name=datasets.Split.VALIDATION,
116
- # These kwargs will be passed to _generate_examples
117
- gen_kwargs={
118
- "filepath": os.path.join(data_dir, "dev.jsonl"),
119
- "split": "dev",
120
- },
121
- ),
122
- datasets.SplitGenerator(
123
- name=f"{self.config.name.split('2')[1]}_corpus",
124
- # These kwargs will be passed to _generate_examples
125
- gen_kwargs={
126
- "filepath": os.path.join(data_dir, "corpus.jsonl"),
127
- "split": f"{self.config.name.split('2')[1]}_corpus",
128
- },
129
- ),
130
- ]
131
-
132
- def _generate_examples(
133
- self, filepath, split # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
134
- ):
135
- """Yields examples as (key, example) tuples."""
136
- # This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
137
- # The `key` is here for legacy reason (tfds) and is not important in itself.
138
-
139
- with open(filepath, encoding="utf-8") as f:
140
- for id_, row in enumerate(f):
141
- data = json.loads(row)
142
- yield id_, {
143
- "document_id": data["document_id"],
144
- "text": data["text"],
145
- "publication_year": data["publication_year"],
146
- "relevant_documents": data["relevant_documents"]
147
- if split != f"{self.config.name.split('2')[1]}_corpus"
148
- else [],
149
- }