File size: 2,648 Bytes
b45e2ce
 
 
 
6c33280
b45e2ce
5a4be59
 
 
 
 
 
 
 
 
 
 
 
 
b45e2ce
b73518b
b45e2ce
b73518b
b45e2ce
 
 
 
 
 
9a1e219
5a4be59
 
 
 
 
 
 
 
 
 
9a1e219
b45e2ce
 
 
 
 
9a1e219
b45e2ce
5a4be59
b45e2ce
 
 
 
6c33280
b45e2ce
 
 
b73518b
b45e2ce
 
 
b73518b
c7d64d9
b73518b
 
b45e2ce
 
319a1b2
 
b45e2ce
 
 
 
 
 
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
import pandas as pd
import datasets
from datasets import GeneratorBasedBuilder

_URL = './data/EuclideaGame.csv'

_CITATION = """\
@misc{mouselinos2024lines,
      title={Beyond Lines and Circles: Unveiling the Geometric Reasoning Gap in Large Language Models}, 
      author={Spyridon Mouselinos and Henryk Michalewski and Mateusz Malinowski},
      year={2024},
      eprint={2402.03877},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
"""



class EuclideaGame(GeneratorBasedBuilder):
    def __init__(self, pack=None, **kwargs):
        super().__init__(**kwargs)
        self.pack = pack

    def _info(self):
        return datasets.DatasetInfo(
            description="This dataset is a collection of the Euclidea "
                        "geometry game levels, alongside their provided solutions.",
            features=datasets.Features({
                "pack": datasets.ClassLabel(
                    names=["Alpha",
                           "Beta",
                           "Gamma",
                           "Delta",
                           "Epsilon",
                           "Zeta",
                           "Eta",
                           "Theta",
                           "Iota",
                           "Kappa",
                           "Lambda"]),
                "level_id": datasets.Value("string"),
                "question": datasets.Value("string"),
                "solution_nl": datasets.Value("string"),
                "solution_tool": datasets.Value("string"),
                "solution_symbol": datasets.Value("string"),
                "initial_symbol": datasets.Value("string")
            }),
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        """Point to local file path within the repository."""
        data_path = dl_manager.download_and_extract(_URL)
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={"filepath": data_path, "pack": self.pack}
            )
        ]

    def _generate_examples(self, filepath, pack=None):
        data = pd.read_csv(filepath)
        if pack:
            data = data[data['pack'].isin(pack)]
        for idx, row in data.iterrows():
            yield idx, {
                'pack': row['pack'],
                'level_id': row['level_id'],
                'question': row['question'],
                'solution_nl': row['solution_nl'],
                'solution_tool': row['solution_tool'],
                'solution_symbol': row['solution_symbol'],
                'initial_symbol': row['initial_symbol']
            }