| | import dataclasses |
| | import itertools |
| | from pathlib import Path |
| | from typing import List |
| |
|
| | import datasets |
| |
|
| | datasets.logging.set_verbosity_info() |
| |
|
| | _DESCRIPTION = """\ |
| | Dataset of music tablature, in alphaTex (https://alphatab.net/docs/alphatex) |
| | format, converted from Guitar Pro files (gp3, gp4, gp5, which are downloaded |
| | from https://rutracker.org/forum/viewtopic.php?t=2888130 |
| | """ |
| |
|
| |
|
| | class Builder(datasets.GeneratorBasedBuilder): |
| | VERSION = datasets.Version("1.5.0") |
| |
|
| | def _info(self): |
| | return datasets.DatasetInfo( |
| | description=_DESCRIPTION, |
| | features=datasets.Features( |
| | { |
| | "text": datasets.Value("string"), |
| | "file": datasets.Value("string"), |
| | } |
| | ), |
| | ) |
| |
|
| | def _split_generators(self, dl_manager: datasets.DownloadManager): |
| | data_dir = dl_manager.download_and_extract("data.zip") |
| | if paths := list(Path(data_dir).glob("**/*.tex")): |
| | print(f"Found {len(paths)} AlphaTex files") |
| | else: |
| | raise ValueError(f"No GP files found in {data_dir}") |
| |
|
| | return [ |
| | datasets.SplitGenerator( |
| | name=datasets.Split.TRAIN, |
| | gen_kwargs={ |
| | "filepaths": paths, |
| | }, |
| | ), |
| | ] |
| |
|
| | def _generate_examples(self, filepaths): |
| | for idx, path in enumerate(filepaths): |
| | with open(path) as f: |
| | yield idx, {"file": path.name, "text": f.read()} |
| |
|