Datasets:
Icannos commited on
Commit ·
fe38569
1
Parent(s): 368d66f
loading script
Browse files- chess_studies.py +75 -0
- train.csv → lichess_studies.csv +0 -0
- others.csv +0 -0
chess_studies.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
"""Chess studies and annotated games from the top lichess studies and from https://www.angelfire.com/games3/smartbridge/"""
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
import pandas as pd
|
| 7 |
+
|
| 8 |
+
import datasets
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
_CITATION = """TO COME."""
|
| 12 |
+
|
| 13 |
+
_DESCRIPTION = """\
|
| 14 |
+
Chess studies and annotated games from the top lichess studies and from https://www.angelfire.com/games3/smartbridge/
|
| 15 |
+
This dataset consists of annotated chess games from several sources and aggregated into a single dataset. It is intended
|
| 16 |
+
to train language models to generate chess games and studies.
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
_HOMEPAGE = ""
|
| 20 |
+
|
| 21 |
+
_LICENSE = "CC0"
|
| 22 |
+
|
| 23 |
+
_URLS = {
|
| 24 |
+
"lichess": "lichess_studies.csv",
|
| 25 |
+
"others": "others.csv",
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class ChessStudies(datasets.GeneratorBasedBuilder):
|
| 30 |
+
|
| 31 |
+
VERSION = datasets.Version("1.0.0")
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
BUILDER_CONFIGS = [
|
| 35 |
+
datasets.BuilderConfig(name="lichess", version=VERSION, description="Top studies scrapped from the lichess website"),
|
| 36 |
+
datasets.BuilderConfig(name="others", version=VERSION, description="Studies aggregated from other sources"),
|
| 37 |
+
]
|
| 38 |
+
|
| 39 |
+
DEFAULT_CONFIG_NAME = "lichess"
|
| 40 |
+
|
| 41 |
+
def _info(self):
|
| 42 |
+
features = datasets.Features(
|
| 43 |
+
{
|
| 44 |
+
"text": datasets.Value("string"),
|
| 45 |
+
}
|
| 46 |
+
)
|
| 47 |
+
return datasets.DatasetInfo(
|
| 48 |
+
description=_DESCRIPTION,
|
| 49 |
+
features=features,
|
| 50 |
+
homepage=_HOMEPAGE,
|
| 51 |
+
license=_LICENSE,
|
| 52 |
+
citation=_CITATION,
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
def _split_generators(self, dl_manager):
|
| 56 |
+
urls = _URLS[self.config.name]
|
| 57 |
+
data_dir = dl_manager.download(urls)
|
| 58 |
+
return [
|
| 59 |
+
datasets.SplitGenerator(
|
| 60 |
+
name=datasets.Split.TRAIN,
|
| 61 |
+
# These kwargs will be passed to _generate_examples
|
| 62 |
+
gen_kwargs={
|
| 63 |
+
"filepath": os.path.join(data_dir),
|
| 64 |
+
"split": "train",
|
| 65 |
+
},
|
| 66 |
+
),
|
| 67 |
+
]
|
| 68 |
+
|
| 69 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 70 |
+
def _generate_examples(self, filepath, split):
|
| 71 |
+
df = pd.read_csv(filepath)
|
| 72 |
+
for i, row in df.iterrows():
|
| 73 |
+
yield i, {
|
| 74 |
+
"text": row['text'],
|
| 75 |
+
}
|
train.csv → lichess_studies.csv
RENAMED
|
File without changes
|
others.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|