Create sticker_queries.py
Browse files- sticker_queries.py +29 -0
sticker_queries.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import load_dataset_builder, GeneratorBasedBuilder, DatasetInfo, SplitGenerator, Split, Value
|
| 2 |
+
|
| 3 |
+
class StickerQueries(GeneratorBasedBuilder):
|
| 4 |
+
def _info(self):
|
| 5 |
+
return DatasetInfo(
|
| 6 |
+
description="Small Stickers, Big Meanings: A Multilingual Sticker Semantic Understanding Dataset with a Gamified Approach,
|
| 7 |
+
features={
|
| 8 |
+
"sticker_id": Value("string"),
|
| 9 |
+
"labeled_queries": Value("string")
|
| 10 |
+
},
|
| 11 |
+
supervised_keys=None,
|
| 12 |
+
homepage="https://huggingface.co/datasets/metchee/sticker-queries",
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
def _split_generators(self, dl_manager):
|
| 16 |
+
data_files = dl_manager.download_and_extract({
|
| 17 |
+
"train": "stickers_queries_en_released.csv"
|
| 18 |
+
})
|
| 19 |
+
return [SplitGenerator(name=Split.TRAIN, gen_kwargs={"filepath": data_files["train"]})]
|
| 20 |
+
|
| 21 |
+
def _generate_examples(self, filepath):
|
| 22 |
+
import csv
|
| 23 |
+
with open(filepath, encoding="utf-8") as f:
|
| 24 |
+
reader = csv.DictReader(f)
|
| 25 |
+
for idx, row in enumerate(reader):
|
| 26 |
+
yield idx, {
|
| 27 |
+
"sticker_id": row["sticker_id"],
|
| 28 |
+
"labeled_queries": row["labeled_queries"]
|
| 29 |
+
}
|