Fraser-Greenlee
commited on
Commit
·
9ee3361
1
Parent(s):
a1b9b69
passing test
Browse files- python_state_changes.py +48 -0
- test.py +8 -0
python_state_changes.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Python State Changes"""
|
| 2 |
+
from random import choice, shuffle
|
| 3 |
+
import datasets
|
| 4 |
+
import json
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
_DESCRIPTION = """\
|
| 8 |
+
Python state changes from a single line of code.
|
| 9 |
+
"""
|
| 10 |
+
_FEATURES = datasets.Features(
|
| 11 |
+
{
|
| 12 |
+
"start": datasets.Value("string"),
|
| 13 |
+
"code": datasets.Value("string"),
|
| 14 |
+
"end": datasets.Value("string"),
|
| 15 |
+
}
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
_LICENSE = "MIT License"
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class PythonStateChanges(datasets.GeneratorBasedBuilder):
|
| 22 |
+
"""Program Synthesis dataset from dreamcoder."""
|
| 23 |
+
|
| 24 |
+
VERSION = datasets.Version("1.1.0")
|
| 25 |
+
BUILDER_CONFIGS = [
|
| 26 |
+
datasets.BuilderConfig(version=VERSION),
|
| 27 |
+
]
|
| 28 |
+
DEFAULT_CONFIG_NAME = "default"
|
| 29 |
+
|
| 30 |
+
def _info(self):
|
| 31 |
+
return datasets.DatasetInfo(
|
| 32 |
+
description=_DESCRIPTION,
|
| 33 |
+
features=_FEATURES,
|
| 34 |
+
supervised_keys=("start", "code", "end"),
|
| 35 |
+
license=_LICENSE,
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
def _split_generators(self, dl_manager):
|
| 39 |
+
return [
|
| 40 |
+
datasets.SplitGenerator(
|
| 41 |
+
name=datasets.Split.TRAIN
|
| 42 |
+
),
|
| 43 |
+
]
|
| 44 |
+
|
| 45 |
+
def _generate_examples(self):
|
| 46 |
+
with open('data.jsonl', 'r', encoding="utf-8") as f:
|
| 47 |
+
for id_, line in enumerate(f):
|
| 48 |
+
yield id_, json.loads(line)
|
test.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datasets
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
data = datasets.load_dataset('python_state_changes.py', streaming=True)
|
| 5 |
+
|
| 6 |
+
for row in data['train']:
|
| 7 |
+
print(row)
|
| 8 |
+
break
|