Datasets:
lmqg
/

Modalities:
Text
Languages:
Korean
ArXiv:
Libraries:
Datasets
License:
asahi417 commited on
Commit
1cb45f8
1 Parent(s): b6ba7f8

Update qag_koquad.py

Browse files
Files changed (1) hide show
  1. qag_koquad.py +79 -0
qag_koquad.py CHANGED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import datasets
3
+
4
+ logger = datasets.logging.get_logger(__name__)
5
+ _VERSION = "0.0.0"
6
+ _NAME = "qag_koquad"
7
+ _CITATION = """
8
+ @inproceedings{ushio-etal-2022-generative,
9
+ title = "{G}enerative {L}anguage {M}odels for {P}aragraph-{L}evel {Q}uestion {G}eneration",
10
+ author = "Ushio, Asahi and
11
+ Alva-Manchego, Fernando and
12
+ Camacho-Collados, Jose",
13
+ booktitle = "Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing",
14
+ month = dec,
15
+ year = "2022",
16
+ address = "Abu Dhabi, U.A.E.",
17
+ publisher = "Association for Computational Linguistics",
18
+ }
19
+ """
20
+ _DESCRIPTION = """Question & answer generation dataset based on SQuAD."""
21
+ _URL = f"https://huggingface.co/datasets/lmqg/{_NAME}/resolve/main/data/processed"
22
+ _URLS = {
23
+ 'train': f'{_URL}/train.jsonl',
24
+ 'test': f'{_URL}/test.jsonl',
25
+ 'validation': f'{_URL}/validation.jsonl'
26
+ }
27
+
28
+
29
+ class QAGKOQuADConfig(datasets.BuilderConfig):
30
+ """BuilderConfig"""
31
+
32
+ def __init__(self, **kwargs):
33
+ """BuilderConfig.
34
+ Args:
35
+ **kwargs: keyword arguments forwarded to super.
36
+ """
37
+ super(QAGKOQuADConfig, self).__init__(**kwargs)
38
+
39
+
40
+ class QAGKOQuAD(datasets.GeneratorBasedBuilder):
41
+
42
+ BUILDER_CONFIGS = [
43
+ QAGKOQuADConfig(name=_NAME, version=datasets.Version(_VERSION), description=_DESCRIPTION),
44
+ ]
45
+
46
+ def _info(self):
47
+ return datasets.DatasetInfo(
48
+ description=_DESCRIPTION,
49
+ features=datasets.Features(
50
+ {
51
+ "answers": datasets.Sequence(datasets.Value("string")),
52
+ "questions": datasets.Sequence(datasets.Value("string")),
53
+ "paragraph": datasets.Value("string"),
54
+ "questions_answers": datasets.Value("string")
55
+ }
56
+ ),
57
+ supervised_keys=None,
58
+ homepage="https://github.com/asahi417/lm-question-generation"
59
+ )
60
+
61
+ def _split_generators(self, dl_manager):
62
+ downloaded_file = dl_manager.download_and_extract(_URLS)
63
+ return [
64
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_file["train"]}),
65
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_file["validation"]}),
66
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_file["test"]}),
67
+ ]
68
+
69
+ def _generate_examples(self, filepath):
70
+ _key = 0
71
+ logger.info("generating examples from = %s", filepath)
72
+ with open(filepath, encoding="utf-8") as f:
73
+ _list = f.read().split('\n')
74
+ if _list[-1] == '':
75
+ _list = _list[:-1]
76
+ for i in _list:
77
+ data = json.loads(i)
78
+ yield _key, data
79
+ _key += 1