davebulaval commited on
Commit
68d33f4
·
1 Parent(s): 308ce55

Delete CSMD.py

Browse files
Files changed (1) hide show
  1. CSMD.py +0 -179
CSMD.py DELETED
@@ -1,179 +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
- """CSMD: a dataset for assessing meaning preservation between sentences"""
16
-
17
- import csv
18
-
19
- import datasets
20
- from datasets import load_dataset
21
-
22
- _CITATION = """\
23
- @ARTICLE{10.3389/frai.2023.1223924,
24
- AUTHOR={Beauchemin, David and Saggion, Horacio and Khoury, Richard},
25
- TITLE={{MeaningBERT: Assessing Meaning Preservation Between Sentences}},
26
- JOURNAL={Frontiers in Artificial Intelligence},
27
- VOLUME={6},
28
- YEAR={2023},
29
- URL={https://www.frontiersin.org/articles/10.3389/frai.2023.1223924},
30
- DOI={10.3389/frai.2023.1223924},
31
- ISSN={2624-8212},
32
- }
33
- """
34
-
35
- _DESCRIPTION = """\
36
- Continuous Scale Meaning Dataset (CSMD) is a dataset for assessing meaning preservation between sentences.
37
- """
38
-
39
- _HOMEPAGE = "https://github.com/GRAAL-Research/csmd"
40
-
41
- _LICENSE = "Attribution 4.0 International (CC BY 4.0)"
42
-
43
- _URL_LIST = [
44
- (
45
- "meaning.train",
46
- "https://github.com/GRAAL-Research/csmd/blob/main/dataset/meaning/train.tsv",
47
- ),
48
- (
49
- "meaning.dev",
50
- "https://github.com/GRAAL-Research/csmd/blob/main/dataset/meaning/dev.tsv",
51
- ),
52
- (
53
- "meaning.test",
54
- "https://github.com/GRAAL-Research/csmd/blob/main/dataset/meaning/test.tsv",
55
- ),
56
- (
57
- "meaning_with_data_augmentation.train",
58
- "https://github.com/GRAAL-Research/csmd/blob/main/dataset/meaning_with_data_augmentation/train.tsv",
59
- ),
60
- (
61
- "meaning_with_data_augmentation.dev",
62
- "https://github.com/GRAAL-Research/csmd/blob/main/dataset/meaning_with_data_augmentation/dev.tsv",
63
- ),
64
- (
65
- "meaning_with_data_augmentation.test",
66
- "https://github.com/GRAAL-Research/csmd/blob/main/dataset/meaning_with_data_augmentation/test.tsv",
67
- ),
68
- (
69
- "identical",
70
- "https://github.com/GRAAL-Research/csmd/blob/main/dataset/holdout/identical.tsv",
71
- ),
72
- (
73
- "unrelated",
74
- "https://github.com/GRAAL-Research/csmd/blob/main/dataset/holdout/unrelated.tsv",
75
- ),
76
- ]
77
-
78
- _URLs = dict(_URL_LIST)
79
-
80
-
81
- class CSMD(datasets.GeneratorBasedBuilder):
82
- VERSION = datasets.Version("2.0.0")
83
-
84
- BUILDER_CONFIGS = [
85
- datasets.BuilderConfig(
86
- name="meaning",
87
- version=VERSION,
88
- description="An instance consists of 1,355 meaning preservation triplets (Document, simplification, "
89
- "label).",
90
- ),
91
- datasets.BuilderConfig(
92
- name="meaning_with_data_augmentation",
93
- version=VERSION,
94
- description="An instance consists of 1,355 meaning preservation triplets (Document, simplification, label) "
95
- "along with 1,355 data augmentation triplets (Document, Document, 1) and 1,355 data "
96
- "augmentation triplets (Document, Unrelated Document, 0) (See the sanity checks in our "
97
- "article).",
98
- ),
99
- datasets.BuilderConfig(
100
- name="meaning_holdout_identical",
101
- version=VERSION,
102
- description="An instance consists of 359 meaning holdout preservation identical triplets (Document, "
103
- "Document, 1) based on the ASSET Simplification dataset.",
104
- ),
105
- datasets.BuilderConfig(
106
- name="meaning_holdout_unrelated",
107
- version=VERSION,
108
- description="An instance consists of 359 meaning holdout preservation unrelated triplets (Document, "
109
- "Unrelated Document, 0) based on the ASSET Simplification dataset.",
110
- ),
111
- ]
112
-
113
- DEFAULT_CONFIG_NAME = "meaning"
114
-
115
- def _info(self):
116
- features = datasets.Features(
117
- {
118
- "document": datasets.Value(dtype="string"),
119
- "simplification": datasets.Value(dtype="string"),
120
- "labels": datasets.Value(dtype="string"),
121
- }
122
- )
123
- return datasets.DatasetInfo(
124
- description=_DESCRIPTION,
125
- features=features,
126
- supervised_keys=None,
127
- homepage=_HOMEPAGE,
128
- license=_LICENSE,
129
- citation=_CITATION,
130
- )
131
-
132
- def _split_generators(self, dl_manager):
133
- data_dir = dl_manager.download_and_extract(_URLs)
134
- if self.config.name in ("meaning", "meaning_with_data_augmentation"):
135
- return [
136
- datasets.SplitGenerator(
137
- name=datasets.Split.TRAIN,
138
- gen_kwargs={
139
- "filepaths": data_dir,
140
- "split": "train",
141
- },
142
- ),
143
- datasets.SplitGenerator(
144
- name=datasets.Split.VALIDATION,
145
- gen_kwargs={
146
- "filepaths": data_dir,
147
- "split": "valid",
148
- },
149
- ),
150
- datasets.SplitGenerator(
151
- name=datasets.Split.TEST,
152
- gen_kwargs={"filepaths": data_dir, "split": "test"},
153
- ),
154
- ]
155
- elif self.config.name in ("identical", "unrelated"):
156
- return [
157
- datasets.SplitGenerator(
158
- name=f"{self.config.name}_{datasets.Split.TEST}",
159
- gen_kwargs={
160
- "filepaths": data_dir,
161
- "split": "test",
162
- },
163
- ),
164
- ]
165
-
166
- def _generate_examples(self, filepaths, split):
167
- with open(filepaths[split], encoding="utf-8") as f:
168
- reader = csv.reader(f, delimiter="\t")
169
- for id_, row in enumerate(reader):
170
- if id_ == 0:
171
- # Columns header
172
- keys = row[:]
173
- else:
174
- res = dict([(k, v) for k, v in zip(keys, row)])
175
- for k in ["document", "simplification", "labels"]:
176
- res[k] = int(res[k])
177
- yield (
178
- id_ - 1
179
- ), res # Minus 1, since first idx is the columns header