python-state-changes / python-state-changes.py
Fraser-Greenlee
fix download
6982d02
raw
history blame
1.33 kB
"""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"),
}
)
_DATA_URL = "https://huggingface.co/datasets/Fraser/python-state-changes/resolve/main/data.jsonl"
_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,
license=_LICENSE,
)
def _split_generators(self, dl_manager):
data_path = dl_manager.download(_DATA_URL)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN, gen_kwargs={'path': data_path}
),
]
def _generate_examples(self, path):
with open(path, 'r', encoding="utf-8") as f:
for id_, line in enumerate(f):
yield id_, json.loads(line)