Upload 2 files
Browse files- glosas_etiquetadas.py +44 -0
- tokenizer.json +0 -0
glosas_etiquetadas.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
import datasets
|
3 |
+
|
4 |
+
_DOWNLOAD_URL = "https://huggingface.co/datasets/cfigueroa/glosas_etiquetadas/blob/main/dataset2.csv"
|
5 |
+
|
6 |
+
class GlosasEtiquetadas(datasets.GeneratorBasedBuilder):
|
7 |
+
"""Glosas Etiquetadas classification dataset."""
|
8 |
+
|
9 |
+
def _info(self):
|
10 |
+
return datasets.DatasetInfo(
|
11 |
+
features=datasets.Features(
|
12 |
+
{
|
13 |
+
"glosa": datasets.Value("string"),
|
14 |
+
"categoria": datasets.ClassLabel(names = ["ACCESORIOS","ALIMENTOS","ANTEOJOS","ASEOPERSONAL","AUTOMOTOR","BANO","BEBE","BEBIDAS","BICICLETAS",
|
15 |
+
"CALEFONT","CARNE","CERVEZA","CONSTRUCCION","DECORACION","DEPORTE","DORMITORIO","ELECTRONICA","ELETRONICA","EQUIPAJE","FERRETERIA","GRIFERIA","HERRAMIENTAS","ILUMINACION",
|
16 |
+
"JARDIN","JOYERIA","JUGUETERIA","LACTEO","LAVANDERIA","LIBRO","LICOR","LIMPIEZA","MASCOTAS","MENAJE","MOBILIARIO","MUSICA","NIEVE","ORGANIZACION","OUTDOOR","PANADERIA",
|
17 |
+
"PARRILLAS","PESCADERIA","PISCINAS","PISOSMUROS","PUERTASVENTANAS","RODADOS","SERVICIOS","TECNOLOGIA","TERRAZAS","UTILES","VESTUARIO","VINO","ZAPATERIA"] ),
|
18 |
+
}
|
19 |
+
)
|
20 |
+
)
|
21 |
+
|
22 |
+
def _split_generators(self, dl_manager):
|
23 |
+
path = dl_manager.download_and_extract(_DOWNLOAD_URL)
|
24 |
+
return [
|
25 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": path, "is_test": False}),
|
26 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": path, "is_test": True}),
|
27 |
+
]
|
28 |
+
|
29 |
+
def _generate_examples(self, filepath, is_test, test_size = 0.3):
|
30 |
+
"""Generate Glosas Etiquetadas examples."""
|
31 |
+
with open(filepath, encoding="utf-8") as csv_file:
|
32 |
+
train_threshold = 70001
|
33 |
+
csv_reader = csv.reader(
|
34 |
+
csv_file
|
35 |
+
)
|
36 |
+
# next(csv_reader, None) # skip the headers
|
37 |
+
for id_, row in enumerate(csv_reader):
|
38 |
+
if id_ > 0:
|
39 |
+
text, label = row
|
40 |
+
current_row = id_, {"glosa": glosa, "categoria": int(categoria)}
|
41 |
+
if (id_ < train_threshold) & (not is_test):
|
42 |
+
yield current_row
|
43 |
+
if (id_ >= train_threshold) & (is_test):
|
44 |
+
yield current_row
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|