Commit
·
9d06a7a
1
Parent(s):
2de58b7
Update test-cefr.py
Browse files- test-cefr.py +111 -7
test-cefr.py
CHANGED
@@ -19,11 +19,11 @@ _HOMEPAGE = ""
|
|
19 |
_LICENSE = ""
|
20 |
|
21 |
|
22 |
-
_URL = "https://huggingface.co/datasets/sebastiaan/test-cefr/
|
23 |
_URLS = {
|
24 |
-
"train": _URL + "
|
25 |
-
"test": _URL + "
|
26 |
-
"val": _URL + "
|
27 |
}
|
28 |
|
29 |
|
@@ -65,7 +65,7 @@ class CefrDataset(datasets.GeneratorBasedBuilder):
|
|
65 |
name=datasets.Split.TRAIN,
|
66 |
# These kwargs will be passed to _generate_examples
|
67 |
gen_kwargs={
|
68 |
-
"filepath": os.path.join(data_dir, "
|
69 |
"split": "train",
|
70 |
},
|
71 |
),
|
@@ -73,7 +73,7 @@ class CefrDataset(datasets.GeneratorBasedBuilder):
|
|
73 |
name=datasets.Split.TEST,
|
74 |
# These kwargs will be passed to _generate_examples
|
75 |
gen_kwargs={
|
76 |
-
"filepath": os.path.join(data_dir, "
|
77 |
"split": "test"
|
78 |
},
|
79 |
),
|
@@ -81,7 +81,111 @@ class CefrDataset(datasets.GeneratorBasedBuilder):
|
|
81 |
name=datasets.Split.VALIDATION,
|
82 |
# These kwargs will be passed to _generate_examples
|
83 |
gen_kwargs={
|
84 |
-
"filepath": os.path.join(data_dir, "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
"split": "val",
|
86 |
},
|
87 |
),
|
|
|
19 |
_LICENSE = ""
|
20 |
|
21 |
|
22 |
+
_URL = "https://huggingface.co/datasets/sebastiaan/test-cefr/resolve/main/"
|
23 |
_URLS = {
|
24 |
+
"train": _URL + "train_dataset.csv",
|
25 |
+
"test": _URL + "test_dataset.csv",
|
26 |
+
"val": _URL + "val_dataset.csv",
|
27 |
}
|
28 |
|
29 |
|
|
|
65 |
name=datasets.Split.TRAIN,
|
66 |
# These kwargs will be passed to _generate_examples
|
67 |
gen_kwargs={
|
68 |
+
"filepath": os.path.join(data_dir, "train_dataset.csv"),
|
69 |
"split": "train",
|
70 |
},
|
71 |
),
|
|
|
73 |
name=datasets.Split.TEST,
|
74 |
# These kwargs will be passed to _generate_examples
|
75 |
gen_kwargs={
|
76 |
+
"filepath": os.path.join(data_dir, "test_dataset.csv"),
|
77 |
"split": "test"
|
78 |
},
|
79 |
),
|
|
|
81 |
name=datasets.Split.VALIDATION,
|
82 |
# These kwargs will be passed to _generate_examples
|
83 |
gen_kwargs={
|
84 |
+
"filepath": os.path.join(data_dir, "val_dataset.csv"),
|
85 |
+
"split": "val",
|
86 |
+
},
|
87 |
+
),
|
88 |
+
]
|
89 |
+
|
90 |
+
def _generate_examples(
|
91 |
+
self, filepath, split
|
92 |
+
):
|
93 |
+
""" Yields examples as (key, example) tuples. """
|
94 |
+
|
95 |
+
with open(filepath, encoding="utf-8") as csv_file:
|
96 |
+
csv_reader = csv.reader(
|
97 |
+
csv_file, quotechar='"', delimiter=",", quoting=csv.QUOTE_ALL, skipinitialspace=True
|
98 |
+
)
|
99 |
+
next(csv_reader, None)
|
100 |
+
for id_, row in enumerate(csv_reader):
|
101 |
+
(prompt, label) = row
|
102 |
+
yield id_, {
|
103 |
+
"prompt": prompt,
|
104 |
+
"label": label
|
105 |
+
}import datasets
|
106 |
+
import csv
|
107 |
+
import os
|
108 |
+
|
109 |
+
_CITATION = """\
|
110 |
+
@InProceedings{huggingface:dataset,
|
111 |
+
title = {A great new dataset},
|
112 |
+
author={huggingface, Inc.
|
113 |
+
},
|
114 |
+
year={2020}
|
115 |
+
}
|
116 |
+
"""
|
117 |
+
|
118 |
+
# You can copy an official description
|
119 |
+
_DESCRIPTION = """\
|
120 |
+
This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
|
121 |
+
"""
|
122 |
+
_HOMEPAGE = ""
|
123 |
+
_LICENSE = ""
|
124 |
+
|
125 |
+
|
126 |
+
_URL = "https://huggingface.co/datasets/sebastiaan/test-cefr/resolve/main/"
|
127 |
+
_URLS = {
|
128 |
+
"train": _URL + "train_dataset.csv",
|
129 |
+
"test": _URL + "test_dataset.csv",
|
130 |
+
"val": _URL + "val_dataset.csv",
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
class CefrDataset(datasets.GeneratorBasedBuilder):
|
135 |
+
|
136 |
+
VERSION = datasets.Version("1.1.0")
|
137 |
+
|
138 |
+
def _info(self):
|
139 |
+
features = datasets.Features(
|
140 |
+
{
|
141 |
+
"prompt": datasets.Value("string"),
|
142 |
+
"label": datasets.Value("string")
|
143 |
+
}
|
144 |
+
)
|
145 |
+
|
146 |
+
return datasets.DatasetInfo(
|
147 |
+
# This is the description that will appear on the datasets page.
|
148 |
+
description=_DESCRIPTION,
|
149 |
+
# This defines the different columns of the dataset and their types
|
150 |
+
features=features, # Here we define them above because they are different between the two configurations
|
151 |
+
# If there's a common (input, target) tuple from the features,
|
152 |
+
# specify them here. They'll be used if as_supervised=True in
|
153 |
+
# builder.as_dataset.
|
154 |
+
supervised_keys=None,
|
155 |
+
# Homepage of the dataset for documentation
|
156 |
+
homepage=_HOMEPAGE,
|
157 |
+
# License for the dataset if available
|
158 |
+
license=_LICENSE,
|
159 |
+
# Citation for the dataset
|
160 |
+
citation=_CITATION,
|
161 |
+
)
|
162 |
+
|
163 |
+
def _split_generators(self, dl_manager):
|
164 |
+
"""Returns SplitGenerators."""
|
165 |
+
my_urls = _URLS
|
166 |
+
data_dir = dl_manager.download_and_extract(my_urls)
|
167 |
+
return [
|
168 |
+
datasets.SplitGenerator(
|
169 |
+
name=datasets.Split.TRAIN,
|
170 |
+
# These kwargs will be passed to _generate_examples
|
171 |
+
gen_kwargs={
|
172 |
+
"filepath": os.path.join(data_dir, "train_dataset.csv"),
|
173 |
+
"split": "train",
|
174 |
+
},
|
175 |
+
),
|
176 |
+
datasets.SplitGenerator(
|
177 |
+
name=datasets.Split.TEST,
|
178 |
+
# These kwargs will be passed to _generate_examples
|
179 |
+
gen_kwargs={
|
180 |
+
"filepath": os.path.join(data_dir, "test_dataset.csv"),
|
181 |
+
"split": "test"
|
182 |
+
},
|
183 |
+
),
|
184 |
+
datasets.SplitGenerator(
|
185 |
+
name=datasets.Split.VALIDATION,
|
186 |
+
# These kwargs will be passed to _generate_examples
|
187 |
+
gen_kwargs={
|
188 |
+
"filepath": os.path.join(data_dir, "val_dataset.csv"),
|
189 |
"split": "val",
|
190 |
},
|
191 |
),
|