missing
Browse files- ChessBot-Dataset.py +6 -31
ChessBot-Dataset.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import logging
|
2 |
from datasets import (
|
3 |
GeneratorBasedBuilder,
|
4 |
DatasetInfo,
|
@@ -8,35 +8,12 @@ from datasets import (
|
|
8 |
Features,
|
9 |
Value,
|
10 |
Array2D,
|
11 |
-
Version,
|
12 |
-
BuilderConfig
|
13 |
)
|
14 |
-
|
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 |
-
|
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(
|
42 |
description="Chess positions + moves + results, streamed from PGN shards",
|
@@ -50,15 +27,14 @@ class ChessPGNDataset(GeneratorBasedBuilder):
|
|
50 |
def _split_generators(self, dl_manager: DownloadManager):
|
51 |
from pathlib import Path, os
|
52 |
|
53 |
-
if self.config.
|
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)
|
@@ -73,7 +49,6 @@ class ChessPGNDataset(GeneratorBasedBuilder):
|
|
73 |
gen_kwargs={"shards": test_paths},
|
74 |
),
|
75 |
]
|
76 |
-
|
77 |
def _generate_examples(self, shards):
|
78 |
import chess.pgn
|
79 |
uid = 0
|
|
|
1 |
+
import logging
|
2 |
from datasets import (
|
3 |
GeneratorBasedBuilder,
|
4 |
DatasetInfo,
|
|
|
8 |
Features,
|
9 |
Value,
|
10 |
Array2D,
|
|
|
|
|
11 |
)
|
|
|
|
|
12 |
from adversarial_gym.chess_env import ChessEnv
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
class ChessPGNDataset(GeneratorBasedBuilder):
|
15 |
VERSION = "0.0.1"
|
16 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def _info(self):
|
18 |
return DatasetInfo(
|
19 |
description="Chess positions + moves + results, streamed from PGN shards",
|
|
|
27 |
def _split_generators(self, dl_manager: DownloadManager):
|
28 |
from pathlib import Path, os
|
29 |
|
30 |
+
if self.config.data_dir:
|
|
|
|
|
|
|
|
|
31 |
repo_root = Path(self.config.data_dir)
|
32 |
train_files = [repo_root / 'train' / f for f in os.listdir(repo_root / 'train')]
|
33 |
test_files = [repo_root / 'test' / f for f in os.listdir(repo_root / 'test')]
|
34 |
|
35 |
+
elif self.config.data_files:
|
36 |
+
train_files = self.config.data_files["train"]
|
37 |
+
test_files = self.config.data_files["test"]
|
38 |
|
39 |
train_paths = dl_manager.download(train_files)
|
40 |
test_paths = dl_manager.download(test_files)
|
|
|
49 |
gen_kwargs={"shards": test_paths},
|
50 |
),
|
51 |
]
|
|
|
52 |
def _generate_examples(self, shards):
|
53 |
import chess.pgn
|
54 |
uid = 0
|