File size: 2,425 Bytes
b22d31c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15c97c2
b22d31c
 
 
 
 
 
 
 
 
 
44e771d
 
 
 
 
b22d31c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44e771d
 
 
 
 
b22d31c
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""TODO: Add a description here."""


import json

import datasets

# TODO: Add BibTeX citation
_CITATION = """\
"""

# TODO: Add description of the dataset here
_DESCRIPTION = """\
"""

# TODO: Add a link to an official homepage for the dataset here
_HOMEPAGE = ""

# TODO: Add the licence for the dataset here if you can find it
_LICENSE = ""

_URL = "https://huggingface.co/datasets/alexjercan/AoC/resolve/main/"
_URLS = {
    "dataset": _URL + "dataset.jsonl",
}


class Bugnet(datasets.GeneratorBasedBuilder):
    """TODO: Short description of my dataset."""

    VERSION = datasets.Version("3.0.1")

    def _info(self):
        features = datasets.Features(
            {
                "year": datasets.Value("string"),
                "day": datasets.Value("string"),
                "part": datasets.Value("string"),
                "pass": datasets.Value("string"),
                "fail": datasets.Value("string"),
                "test": datasets.Value("string"),
                "change": datasets.Value("string"),
                "i1": datasets.Value("uint32"),
                "i2": datasets.Value("uint32"),
                "j1": datasets.Value("uint32"),
                "j2": datasets.Value("uint32"),
            }
        )

        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            homepage=_HOMEPAGE,
            license=_LICENSE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        data_dir = dl_manager.download_and_extract(_URLS)
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={"filepath": data_dir["dataset"]},
            ),
        ]

    def _generate_examples(self, filepath):
        with open(filepath, encoding="utf-8") as file:
            for key, row in enumerate(file):
                data = json.loads(row)

                yield key, {
                    "year": data["year"],
                    "day": data["day"],
                    "part": data["part"],
                    "pass": data["pass"],
                    "fail": data["fail"],
                    "test": data["test"],
                    "change": data["change"],
                    "i1": data["i1"],
                    "i2": data["i2"],
                    "j1": data["j1"],
                    "j2": data["j2"],
                }