|
from pandas import read_csv |
|
|
|
from datasets import GeneratorBasedBuilder, Value, Version, BuilderConfig, Features, DatasetInfo, SplitGenerator, Split |
|
|
|
_DESCRIPTION = ''' |
|
This dataset contains transcribed sounds emitted by characters of the League of Legends game. |
|
The data can be useful for building text classification models, fine-tuning language generation models, speech synthesis and speech recognition models. |
|
The underlying web dump for the dataset construction has been last refreshed **20.10.2023** |
|
''' |
|
|
|
_HOMEPAGE = 'https://huggingface.co/datasets/zeio/pale' |
|
|
|
_LICENSE = 'Apache License Version 2.0' |
|
|
|
_URLS = { |
|
'full': 'https://huggingface.co/datasets/zeio/pale/resolve/main/pale.tsv', |
|
'quotes': 'https://huggingface.co/datasets/zeio/pale/resolve/main/quotes.tsv', |
|
'annotated': 'https://huggingface.co/datasets/zeio/pale/resolve/main/annotated.tsv' |
|
} |
|
|
|
|
|
class Pale(GeneratorBasedBuilder): |
|
|
|
VERSION = Version('27.10.2023') |
|
|
|
BUILDER_CONFIGS = [ |
|
BuilderConfig(name = 'quotes', version = VERSION, description = 'Truncated version of the corpus, which does\'t contain sound effects'), |
|
BuilderConfig(name = 'annotated', version = VERSION, description = 'An extended version of the full configuration with a couple of additional columns with labels'), |
|
BuilderConfig(name = 'vanilla', version = VERSION, description = 'All data pulled from the website without significant modifications apart from the web page structure parsing') |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = 'quotes' |
|
|
|
def _info(self): |
|
if self.config.name == 'vanilla': |
|
features = Features({ |
|
'header': Value('string'), |
|
'subheader': Value('string'), |
|
'text': Value('string'), |
|
'source': Value('string'), |
|
'champion': Value('string') |
|
}) |
|
elif self.config.name == 'annotated': |
|
features = Features({ |
|
'header': Value('string'), |
|
'subheader': Value('string'), |
|
'text': Value('string'), |
|
'source': Value('string'), |
|
'champion': Value('string'), |
|
'quote': Value('bool') |
|
}) |
|
elif self.config.name == 'quotes': |
|
features = Features({ |
|
'header': Value('string'), |
|
'subheader': Value('string'), |
|
'text': Value('string'), |
|
'champion': Value('string') |
|
}) |
|
|
|
return DatasetInfo( |
|
description=_DESCRIPTION, |
|
features = features, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
name = self.config.name |
|
|
|
url = _URLS[name] |
|
|
|
return [ |
|
SplitGenerator( |
|
name = Split.TRAIN, |
|
gen_kwargs = { |
|
"path": dl_manager.download_and_extract(url) |
|
} |
|
) |
|
] |
|
|
|
def _generate_examples(self, path: str): |
|
for i, row in read_csv(path, sep = '\t').iterrows(): |
|
yield i, dict(row) |
|
|