Datasets:
vladsaveliev commited on
Commit ·
db69b55
1
Parent(s): 3476d46
Add script
Browse files- .gitignore +1 -0
- guitar_tab.py +60 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.DS_Store
|
guitar_tab.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from lxml import etree
|
| 4 |
+
import datasets
|
| 5 |
+
|
| 6 |
+
datasets.logging.set_verbosity_info()
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
_DESCRIPTION = """\
|
| 10 |
+
Dataset from alphaTex files (https://alphatab.net/docs/alphatex), converted from Guitar Pro files, downlaoded
|
| 11 |
+
from https://rutracker.org/forum/viewtopic.php?t=2888130
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class Builder(datasets.GeneratorBasedBuilder):
|
| 16 |
+
VERSION = datasets.Version("1.1.0")
|
| 17 |
+
|
| 18 |
+
def _info(self):
|
| 19 |
+
return datasets.DatasetInfo(
|
| 20 |
+
description=_DESCRIPTION,
|
| 21 |
+
features=datasets.Features(
|
| 22 |
+
{
|
| 23 |
+
"text": datasets.Value("string"),
|
| 24 |
+
"title": datasets.Value("string"),
|
| 25 |
+
"artist": datasets.Value("string"),
|
| 26 |
+
"instrument": datasets.Value("string"),
|
| 27 |
+
}
|
| 28 |
+
),
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
| 32 |
+
data_dir = dl_manager.download_and_extract("data.zip")
|
| 33 |
+
if tex_paths := list(Path(data_dir).glob("**/*.tex")):
|
| 34 |
+
print(f"Found {len(tex_paths)} alphaTex files")
|
| 35 |
+
else:
|
| 36 |
+
raise ValueError(f"No alphaTex files found in {tex_paths}")
|
| 37 |
+
|
| 38 |
+
return [
|
| 39 |
+
datasets.SplitGenerator(
|
| 40 |
+
name=datasets.Split.TRAIN,
|
| 41 |
+
gen_kwargs={
|
| 42 |
+
"filepaths": [p for p in tex_paths],
|
| 43 |
+
},
|
| 44 |
+
),
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
def _generate_examples(self, filepaths):
|
| 48 |
+
for fileidx, filepath in enumerate(filepaths):
|
| 49 |
+
with Path(filepath).open("r") as f:
|
| 50 |
+
text = f.read()
|
| 51 |
+
meta = {
|
| 52 |
+
l.strip().lstrip("\\").split(" ", 1)
|
| 53 |
+
for l in text.split(".").split("\n")
|
| 54 |
+
if l.strip()
|
| 55 |
+
}
|
| 56 |
+
yield fileidx, {
|
| 57 |
+
"text": text,
|
| 58 |
+
"title": filepath.stem,
|
| 59 |
+
"instrument": meta.get("instrument"),
|
| 60 |
+
}
|