Datasets:
feat(dataset-loader): added dataset loader script
Browse files
pale.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pandas import read_csv
|
2 |
+
|
3 |
+
from datasets import GeneratorBasedBuilder, Value, Version, BuilderConfig, Features, DatasetInfo, SplitGenerator, Split
|
4 |
+
|
5 |
+
_DESCRIPTION = '''
|
6 |
+
This dataset contains transcribed sounds emitted by characters of the League of Legends game.
|
7 |
+
The data can be useful for building text classification models, fine-tuning language generation models, speech synthesis and speech recognition models.
|
8 |
+
The underlying web dump for the dataset construction has been last refreshed **20.10.2023**
|
9 |
+
'''
|
10 |
+
|
11 |
+
_HOMEPAGE = 'https://huggingface.co/datasets/zeio/pale'
|
12 |
+
|
13 |
+
_LICENSE = 'Apache License Version 2.0'
|
14 |
+
|
15 |
+
_URLS = {
|
16 |
+
'full': 'https://huggingface.co/datasets/zeio/pale/resolve/main/pale.tsv',
|
17 |
+
'quotes': 'https://huggingface.co/datasets/zeio/pale/resolve/main/quotes.tsv',
|
18 |
+
'annotated': 'https://huggingface.co/datasets/zeio/pale/resolve/main/annotated.tsv'
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
class Pale(GeneratorBasedBuilder):
|
23 |
+
|
24 |
+
VERSION = Version('27.10.2023')
|
25 |
+
|
26 |
+
BUILDER_CONFIGS = [
|
27 |
+
BuilderConfig(name = 'quotes', version = VERSION, description = 'Truncated version of the corpus, which does\'t contain sound effects'),
|
28 |
+
BuilderConfig(name = 'annotated', version = VERSION, description = 'An extended version of the full configuration with a couple of additional columns with labels'),
|
29 |
+
BuilderConfig(name = 'vanilla', version = VERSION, description = 'All data pulled from the website without significant modifications apart from the web page structure parsing')
|
30 |
+
]
|
31 |
+
|
32 |
+
DEFAULT_CONFIG_NAME = 'quotes'
|
33 |
+
|
34 |
+
def _info(self):
|
35 |
+
if self.config.name == 'vanilla':
|
36 |
+
features = Features({
|
37 |
+
'header': Value('string'),
|
38 |
+
'subheader': Value('string'),
|
39 |
+
'text': Value('string'),
|
40 |
+
'source': Value('string'),
|
41 |
+
'champion': Value('string')
|
42 |
+
})
|
43 |
+
elif self.config.name == 'annotated':
|
44 |
+
features = Features({
|
45 |
+
'header': Value('string'),
|
46 |
+
'subheader': Value('string'),
|
47 |
+
'text': Value('string'),
|
48 |
+
'source': Value('string'),
|
49 |
+
'champion': Value('string'),
|
50 |
+
'quote': Value('bool')
|
51 |
+
})
|
52 |
+
elif self.config.name == 'quotes':
|
53 |
+
features = Features({
|
54 |
+
'header': Value('string'),
|
55 |
+
'subheader': Value('string'),
|
56 |
+
'text': Value('string'),
|
57 |
+
'champion': Value('string')
|
58 |
+
})
|
59 |
+
|
60 |
+
return DatasetInfo(
|
61 |
+
description=_DESCRIPTION,
|
62 |
+
features = features,
|
63 |
+
homepage=_HOMEPAGE,
|
64 |
+
license=_LICENSE
|
65 |
+
)
|
66 |
+
|
67 |
+
def _split_generators(self, dl_manager):
|
68 |
+
name = self.config.name
|
69 |
+
|
70 |
+
url = _URLS[name]
|
71 |
+
|
72 |
+
return [
|
73 |
+
SplitGenerator(
|
74 |
+
name = Split.TRAIN,
|
75 |
+
gen_kwargs = {
|
76 |
+
"path": dl_manager.download_and_extract(url)
|
77 |
+
}
|
78 |
+
)
|
79 |
+
]
|
80 |
+
|
81 |
+
def _generate_examples(self, path: str):
|
82 |
+
for i, row in read_csv(path, sep = '\t').iterrows():
|
83 |
+
yield i, dict(row)
|