missing
Browse files- ChessBot-Dataset.py +23 -16
ChessBot-Dataset.py
CHANGED
@@ -15,20 +15,27 @@ from datasets import (
|
|
15 |
from datasets.data_files import sanitize_patterns, DataFilesDict
|
16 |
from adversarial_gym.chess_env import ChessEnv
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
class ChessPGNDataset(GeneratorBasedBuilder):
|
19 |
VERSION = "0.0.1"
|
20 |
BUILDER_CONFIGS = [
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
]
|
32 |
|
33 |
def _info(self):
|
34 |
return DatasetInfo(
|
@@ -43,15 +50,15 @@ class ChessPGNDataset(GeneratorBasedBuilder):
|
|
43 |
def _split_generators(self, dl_manager: DownloadManager):
|
44 |
from pathlib import Path, os
|
45 |
|
46 |
-
if self.config.
|
|
|
|
|
|
|
|
|
47 |
repo_root = Path(self.config.data_dir)
|
48 |
train_files = [repo_root / 'train' / f for f in os.listdir(repo_root / 'train')]
|
49 |
test_files = [repo_root / 'test' / f for f in os.listdir(repo_root / 'test')]
|
50 |
|
51 |
-
elif self.config.data_files:
|
52 |
-
train_files = self.config.data_files["train"]
|
53 |
-
test_files = self.config.data_files["test"]
|
54 |
-
|
55 |
|
56 |
train_paths = dl_manager.download(train_files)
|
57 |
test_paths = dl_manager.download(test_files)
|
|
|
15 |
from datasets.data_files import sanitize_patterns, DataFilesDict
|
16 |
from adversarial_gym.chess_env import ChessEnv
|
17 |
|
18 |
+
|
19 |
+
|
20 |
+
class ChessPGNConfig(BuilderConfig):
|
21 |
+
def __init__(self, *, data_files: dict, **kwargs):
|
22 |
+
super().__init__(**kwargs)
|
23 |
+
# data_files is just {"train":"train/*.pgn", "test":"test/*.pgn"}
|
24 |
+
self.data_files = data_files
|
25 |
+
|
26 |
class ChessPGNDataset(GeneratorBasedBuilder):
|
27 |
VERSION = "0.0.1"
|
28 |
BUILDER_CONFIGS = [
|
29 |
+
ChessPGNConfig(
|
30 |
+
name="default",
|
31 |
+
version=Version("0.0.3"), # bump this each time you update the script
|
32 |
+
description="PGN shards of chess games",
|
33 |
+
data_files={
|
34 |
+
"train": "train/*.pgn",
|
35 |
+
"test": "test/*.pgn",
|
36 |
+
},
|
37 |
+
),
|
38 |
+
]
|
|
|
39 |
|
40 |
def _info(self):
|
41 |
return DatasetInfo(
|
|
|
50 |
def _split_generators(self, dl_manager: DownloadManager):
|
51 |
from pathlib import Path, os
|
52 |
|
53 |
+
if self.config.data_files:
|
54 |
+
train_files = self.config.data_files["train"]
|
55 |
+
test_files = self.config.data_files["test"]
|
56 |
+
|
57 |
+
elif self.config.data_dir or self.config.data_files is None:
|
58 |
repo_root = Path(self.config.data_dir)
|
59 |
train_files = [repo_root / 'train' / f for f in os.listdir(repo_root / 'train')]
|
60 |
test_files = [repo_root / 'test' / f for f in os.listdir(repo_root / 'test')]
|
61 |
|
|
|
|
|
|
|
|
|
62 |
|
63 |
train_paths = dl_manager.download(train_files)
|
64 |
test_paths = dl_manager.download(test_files)
|