Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
10K - 100K
ArXiv:
Tags:
question-generation
License:
init
Browse files- qg_squad.py +14 -9
qg_squad.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import datasets
|
2 |
from datasets import load_dataset
|
3 |
from datasets.tasks import Summarization
|
@@ -53,14 +54,18 @@ class SquadQG(datasets.GeneratorBasedBuilder):
|
|
53 |
def _split_generators(self, dl_manager):
|
54 |
downloaded_file = dl_manager.download_and_extract(_URLS)
|
55 |
return [
|
56 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"
|
57 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"
|
58 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"
|
59 |
]
|
60 |
|
61 |
-
def _generate_examples(self,
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
import datasets
|
3 |
from datasets import load_dataset
|
4 |
from datasets.tasks import Summarization
|
|
|
54 |
def _split_generators(self, dl_manager):
|
55 |
downloaded_file = dl_manager.download_and_extract(_URLS)
|
56 |
return [
|
57 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": downloaded_file["train"]}),
|
58 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepaths": downloaded_file["validation"]}),
|
59 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepaths": downloaded_file["test"]}),
|
60 |
]
|
61 |
|
62 |
+
def _generate_examples(self, filepaths):
|
63 |
+
for filepath in filepaths:
|
64 |
+
logger.info("generating examples from = %s", filepath)
|
65 |
+
with open(filepath, encoding="utf-8") as f:
|
66 |
+
_list = f.read().split('\n')
|
67 |
+
if _list[-1] == '':
|
68 |
+
_list = _list[:-1]
|
69 |
+
for _id, i in enumerate(_list):
|
70 |
+
data = json.loads(i)
|
71 |
+
yield _id, data
|