Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
csv
Languages:
English
Size:
10K - 100K
License:
Upload clef24_dataset_en.py
Browse files- clef24_dataset_en.py +73 -0
clef24_dataset_en.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Multilang Dataset loading script."""
|
2 |
+
|
3 |
+
from datasets import DatasetDict, DatasetInfo, BuilderConfig, Version, GeneratorBasedBuilder
|
4 |
+
from datasets import SplitGenerator, Split, Features, Value
|
5 |
+
|
6 |
+
import os
|
7 |
+
|
8 |
+
_DESCRIPTION = """
|
9 |
+
This dataset includes multilingual data for language classification tasks across several languages.
|
10 |
+
"""
|
11 |
+
|
12 |
+
_CITATION = """\
|
13 |
+
@InProceedings{huggingface:multilang_dataset,
|
14 |
+
title = {Multilingual Text Dataset},
|
15 |
+
authors = {Your Name},
|
16 |
+
year = {2024}
|
17 |
+
}
|
18 |
+
"""
|
19 |
+
|
20 |
+
_LICENSE = "Your dataset's license here."
|
21 |
+
|
22 |
+
class MultilangDataset(GeneratorBasedBuilder):
|
23 |
+
"""A multilingual text dataset."""
|
24 |
+
|
25 |
+
BUILDER_CONFIGS = [
|
26 |
+
BuilderConfig(name="multilang_dataset", version=Version("1.0.0"), description="Multilingual dataset for text classification."),
|
27 |
+
]
|
28 |
+
|
29 |
+
DEFAULT_CONFIG_NAME = "multilang_dataset" # Default configuration name.
|
30 |
+
|
31 |
+
def _info(self):
|
32 |
+
return DatasetInfo(
|
33 |
+
description=_DESCRIPTION,
|
34 |
+
features=Features({
|
35 |
+
"Sentence_id": Value("string"),
|
36 |
+
"Text": Value("string"),
|
37 |
+
"class_label": Value("string"),
|
38 |
+
}),
|
39 |
+
supervised_keys=("Text", "class_label"),
|
40 |
+
homepage="https://www.example.com",
|
41 |
+
citation=_CITATION,
|
42 |
+
license=_LICENSE,
|
43 |
+
)
|
44 |
+
|
45 |
+
def _split_generators(self, dl_manager):
|
46 |
+
"""Returns SplitGenerators."""
|
47 |
+
# Assumes your dataset is located in "path/to/dataset"
|
48 |
+
data_dir = os.path.abspath("data/")
|
49 |
+
splits = ["train", "dev", "dev-test"]
|
50 |
+
|
51 |
+
return [
|
52 |
+
SplitGenerator(
|
53 |
+
name=Split.TRAIN,
|
54 |
+
gen_kwargs={
|
55 |
+
"filepath": os.path.join(data_dir, f"{split}.tsv"),
|
56 |
+
"split": split
|
57 |
+
},
|
58 |
+
)
|
59 |
+
for split in splits
|
60 |
+
]
|
61 |
+
|
62 |
+
def _generate_examples(self, filepath, split):
|
63 |
+
"""Yields examples."""
|
64 |
+
with open(filepath, encoding="utf-8") as f:
|
65 |
+
for id_, row in enumerate(f):
|
66 |
+
if id_ == 0: # Optionally skip header
|
67 |
+
continue
|
68 |
+
cols = row.strip().split('\t')
|
69 |
+
yield f"{split}_{id_}", {
|
70 |
+
"sentence_id": cols[0],
|
71 |
+
"sentence": cols[1],
|
72 |
+
"label": cols[2],
|
73 |
+
}
|