"""Python State Changes""" from random import choice, shuffle import datasets import json _DESCRIPTION = """\ Python state changes from a single line of code. """ _FEATURES = datasets.Features( { "start": datasets.Value("string"), "code": datasets.Value("string"), "end": datasets.Value("string"), } ) _LICENSE = "MIT License" class PythonStateChanges(datasets.GeneratorBasedBuilder): """Program Synthesis dataset from dreamcoder.""" VERSION = datasets.Version("1.1.0") BUILDER_CONFIGS = [ datasets.BuilderConfig(version=VERSION), ] DEFAULT_CONFIG_NAME = "default" def _info(self): return datasets.DatasetInfo( description=_DESCRIPTION, features=_FEATURES, supervised_keys=("start", "code", "end"), license=_LICENSE, ) def _split_generators(self, dl_manager): return [ datasets.SplitGenerator( name=datasets.Split.TRAIN ), ] def _generate_examples(self): with open('data.jsonl', 'r', encoding="utf-8") as f: for id_, line in enumerate(f): yield id_, json.loads(line)