Commit ·
877c537
1
Parent(s): 0adbf09
Update test-cefr.py
Browse files- test-cefr.py +19 -7
test-cefr.py
CHANGED
|
@@ -1,8 +1,5 @@
|
|
| 1 |
-
import csv
|
| 2 |
-
import json
|
| 3 |
-
import os
|
| 4 |
-
|
| 5 |
import datasets
|
|
|
|
| 6 |
|
| 7 |
_CITATION = """\
|
| 8 |
@InProceedings{huggingface:dataset,
|
|
@@ -59,8 +56,6 @@ class CefrDataset(datasets.GeneratorBasedBuilder):
|
|
| 59 |
|
| 60 |
def _split_generators(self, dl_manager):
|
| 61 |
"""Returns SplitGenerators."""
|
| 62 |
-
|
| 63 |
-
|
| 64 |
return [
|
| 65 |
datasets.SplitGenerator(
|
| 66 |
name=datasets.Split.TRAIN,
|
|
@@ -86,4 +81,21 @@ class CefrDataset(datasets.GeneratorBasedBuilder):
|
|
| 86 |
"split": "val",
|
| 87 |
},
|
| 88 |
),
|
| 89 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import datasets
|
| 2 |
+
import csv
|
| 3 |
|
| 4 |
_CITATION = """\
|
| 5 |
@InProceedings{huggingface:dataset,
|
|
|
|
| 56 |
|
| 57 |
def _split_generators(self, dl_manager):
|
| 58 |
"""Returns SplitGenerators."""
|
|
|
|
|
|
|
| 59 |
return [
|
| 60 |
datasets.SplitGenerator(
|
| 61 |
name=datasets.Split.TRAIN,
|
|
|
|
| 81 |
"split": "val",
|
| 82 |
},
|
| 83 |
),
|
| 84 |
+
]
|
| 85 |
+
|
| 86 |
+
def _generate_examples(
|
| 87 |
+
self, filepath, split
|
| 88 |
+
):
|
| 89 |
+
""" Yields examples as (key, example) tuples. """
|
| 90 |
+
|
| 91 |
+
with open(filepath, encoding="utf-8") as csv_file:
|
| 92 |
+
csv_reader = csv.reader(
|
| 93 |
+
csv_file, quotechar='"', delimiter=",", quoting=csv.QUOTE_ALL, skipinitialspace=True
|
| 94 |
+
)
|
| 95 |
+
next(csv_reader, None)
|
| 96 |
+
for id_, row in enumerate(csv_reader):
|
| 97 |
+
(prompt, label) = row
|
| 98 |
+
yield id_, {
|
| 99 |
+
"prompt": prompt,
|
| 100 |
+
"label": label
|
| 101 |
+
}
|