File size: 2,373 Bytes
5116c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Genericify C++ Dataset for CS7470"""


import json

import datasets


# You can copy an official description
_DESCRIPTION = """\
Genericify C++ Dataset
"""


class DatasetGenericifyCpp(datasets.GeneratorBasedBuilder):
    """Genericify C++ Dataset for CS7470"""

    VERSION = datasets.Version("1.1.0")

    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "task_id": datasets.Value("string"),
                    "base_prompt": datasets.Value("string"),
                    "sfinae_prompt": datasets.Value("string"),
                    "concepts_prompt": datasets.Value("string"),
                    "starter_code": datasets.Value("string"),
                    "base_canonical_solution": datasets.Value("string"),
                    "sfinae_canonical_solution": datasets.Value("string"),
                    "concepts_canonical_solution": datasets.Value("string"),
                    "tests": datasets.Value("string"),
                    "invalids": datasets.Value("string"),
                }
            ),
        )

    def _split_generators(self, dl_manager):
        downloaded_files = dl_manager.download_and_extract(
            "data/genericify_cpp.jsonl"
        )
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TEST,
                gen_kwargs={
                    "filepath": downloaded_files,
                },
            ),
        ]

    def _generate_examples(self, filepath):
        with open(filepath, encoding="utf-8") as f:
            for key, line in enumerate(f):
                row = json.loads(line)
                yield key, {
                    "task_id": row["task_id"],
                    "base_prompt": row["base_prompt"],
                    "sfinae_prompt": row["sfinae_prompt"],
                    "concepts_prompt": row["concepts_prompt"],
                    "starter_code": row["starter_code"],
                    "base_canonical_solution": row["base_canonical_solution"],
                    "sfinae_canonical_solution": row["sfinae_canonical_solution"],
                    "concepts_canonical_solution": row["concepts_canonical_solution"],
                    "tests": row["tests"],
                    "invalids": row["invalids"],
                }