Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
json
Sub-tasks:
multi-class-classification
Languages:
Catalan
Size:
100K - 1M
License:
Delete tecla.py
Browse files
tecla.py
DELETED
|
@@ -1,157 +0,0 @@
|
|
| 1 |
-
# Loading script for the TeCla dataset.
|
| 2 |
-
import json
|
| 3 |
-
import datasets
|
| 4 |
-
|
| 5 |
-
logger = datasets.logging.get_logger(__name__)
|
| 6 |
-
|
| 7 |
-
_CITATION = """
|
| 8 |
-
Baucells, Irene, Carrino, Casimiro Pio, Rodriguez-Penagos, Carlos Gerardo, & Armentano-Oller, Carme. (2021).
|
| 9 |
-
TeCla: Text Classification Catalan dataset (Version 2.0) [Data set].
|
| 10 |
-
Zenodo. http://doi.org/10.5281/zenodo.7334110
|
| 11 |
-
"""
|
| 12 |
-
|
| 13 |
-
_DESCRIPTION = """
|
| 14 |
-
TeCla: Text Classification Catalan dataset
|
| 15 |
-
Catalan News corpus for Text classification, crawled from ACN (Catalan News Agency) site: www.acn.cat
|
| 16 |
-
Corpus de notícies en català per a classificació textual, extret del web de l'Agència Catalana de Notícies - www.acn.cat
|
| 17 |
-
"""
|
| 18 |
-
|
| 19 |
-
_HOMEPAGE = """https://zenodo.org/record/4761505"""
|
| 20 |
-
|
| 21 |
-
# TODO: upload datasets to github
|
| 22 |
-
_URL = "./"
|
| 23 |
-
_TRAINING_FILE = "train.json"
|
| 24 |
-
_DEV_FILE = "dev.json"
|
| 25 |
-
_TEST_FILE = "test.json"
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
class teclaConfig(datasets.BuilderConfig):
|
| 29 |
-
""" Builder config for the TeCla dataset """
|
| 30 |
-
|
| 31 |
-
def __init__(self, **kwargs):
|
| 32 |
-
"""BuilderConfig for TeCla.
|
| 33 |
-
Args:
|
| 34 |
-
**kwargs: keyword arguments forwarded to super.
|
| 35 |
-
"""
|
| 36 |
-
super(teclaConfig, self).__init__(**kwargs)
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
class tecla(datasets.GeneratorBasedBuilder):
|
| 40 |
-
""" TeCla Dataset """
|
| 41 |
-
|
| 42 |
-
BUILDER_CONFIGS = [
|
| 43 |
-
teclaConfig(
|
| 44 |
-
name="tecla",
|
| 45 |
-
version=datasets.Version("1.0.1"),
|
| 46 |
-
description="tecla 2.0 dataset",
|
| 47 |
-
),
|
| 48 |
-
]
|
| 49 |
-
|
| 50 |
-
def _info(self):
|
| 51 |
-
return datasets.DatasetInfo(
|
| 52 |
-
description=_DESCRIPTION,
|
| 53 |
-
features=datasets.Features(
|
| 54 |
-
{
|
| 55 |
-
"text": datasets.Value("string"),
|
| 56 |
-
"label1": datasets.features.ClassLabel
|
| 57 |
-
(names=
|
| 58 |
-
[
|
| 59 |
-
"Societat",
|
| 60 |
-
"Pol\u00edtica",
|
| 61 |
-
"Economia",
|
| 62 |
-
"Cultura",
|
| 63 |
-
]
|
| 64 |
-
),
|
| 65 |
-
"label2": datasets.features.ClassLabel
|
| 66 |
-
(names=
|
| 67 |
-
[
|
| 68 |
-
"Llengua",
|
| 69 |
-
"Infraestructures",
|
| 70 |
-
"Arts",
|
| 71 |
-
"Parlament",
|
| 72 |
-
"Noves tecnologies",
|
| 73 |
-
"Castells",
|
| 74 |
-
"Successos",
|
| 75 |
-
"Empresa",
|
| 76 |
-
"Mobilitat",
|
| 77 |
-
"Teatre",
|
| 78 |
-
"Treball",
|
| 79 |
-
"Log\u00edstica",
|
| 80 |
-
"Urbanisme",
|
| 81 |
-
"Govern",
|
| 82 |
-
"Entitats",
|
| 83 |
-
"Finances",
|
| 84 |
-
"Govern espanyol",
|
| 85 |
-
"Tr\u00e0nsit",
|
| 86 |
-
"Ind\u00fastria",
|
| 87 |
-
"Esports",
|
| 88 |
-
"Exteriors",
|
| 89 |
-
"Medi ambient",
|
| 90 |
-
"Habitatge",
|
| 91 |
-
"Salut",
|
| 92 |
-
"Equipaments i patrimoni",
|
| 93 |
-
"Recerca",
|
| 94 |
-
"Cooperaci\u00f3",
|
| 95 |
-
"Innovaci\u00f3",
|
| 96 |
-
"Agroalimentaci\u00f3",
|
| 97 |
-
"Policial",
|
| 98 |
-
"Serveis Socials",
|
| 99 |
-
"Cinema",
|
| 100 |
-
"Mem\u00f2ria hist\u00f2rica",
|
| 101 |
-
"Turisme",
|
| 102 |
-
"Pol\u00edtica municipal",
|
| 103 |
-
"Comer\u00e7",
|
| 104 |
-
"Universitats",
|
| 105 |
-
"Hisenda",
|
| 106 |
-
"Judicial",
|
| 107 |
-
"Partits",
|
| 108 |
-
"M\u00fasica",
|
| 109 |
-
"Lletres",
|
| 110 |
-
"Religi\u00f3",
|
| 111 |
-
"Festa i cultura popular",
|
| 112 |
-
"Uni\u00f3 Europea",
|
| 113 |
-
"Moda",
|
| 114 |
-
"Moviments socials",
|
| 115 |
-
"Comptes p\u00fablics",
|
| 116 |
-
"Immigraci\u00f3",
|
| 117 |
-
"Educaci\u00f3",
|
| 118 |
-
"Gastronomia",
|
| 119 |
-
"Meteorologia",
|
| 120 |
-
"Energia"
|
| 121 |
-
]
|
| 122 |
-
),
|
| 123 |
-
}
|
| 124 |
-
),
|
| 125 |
-
homepage=_HOMEPAGE,
|
| 126 |
-
citation=_CITATION,
|
| 127 |
-
)
|
| 128 |
-
|
| 129 |
-
def _split_generators(self, dl_manager):
|
| 130 |
-
"""Returns SplitGenerators."""
|
| 131 |
-
urls_to_download = {
|
| 132 |
-
"train": f"{_URL}{_TRAINING_FILE}",
|
| 133 |
-
"dev": f"{_URL}{_DEV_FILE}",
|
| 134 |
-
"test": f"{_URL}{_TEST_FILE}",
|
| 135 |
-
}
|
| 136 |
-
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
| 137 |
-
|
| 138 |
-
return [
|
| 139 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
| 140 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
| 141 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
| 142 |
-
]
|
| 143 |
-
|
| 144 |
-
def _generate_examples(self, filepath):
|
| 145 |
-
"""This function returns the examples in the raw (text) form."""
|
| 146 |
-
logger.info("generating examples from = %s", filepath)
|
| 147 |
-
with open(filepath, encoding="utf-8") as f:
|
| 148 |
-
acn_ca = json.load(f)
|
| 149 |
-
for id_, article in enumerate(acn_ca["data"]):
|
| 150 |
-
text = article["sentence"]
|
| 151 |
-
label1 = article["label1"]
|
| 152 |
-
label2 = article["label2"]
|
| 153 |
-
yield id_, {
|
| 154 |
-
"text": text,
|
| 155 |
-
"label1": label1,
|
| 156 |
-
"label2": label2,
|
| 157 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|