Miguel Gómez Prieto commited on
Commit
f0ffbdc
·
1 Parent(s): 2d4f610

Update visualizer code

Browse files
Files changed (1) hide show
  1. job_offers_esp.py +34 -28
job_offers_esp.py CHANGED
@@ -1,46 +1,52 @@
1
  import csv
2
- from datasets import DatasetInfo, GeneratorBasedBuilder, SplitGenerator, Split
3
 
4
- class JobOffersESP(GeneratorBasedBuilder):
5
- VERSION = "1.0.0"
6
 
7
  def _info(self):
8
- return DatasetInfo(
9
  description="Dataset de ofertas laborales en español extraídas de EURES y fuentes autonómicas.",
10
- features={
11
- "url": {"dtype": "string"},
12
- "fecha_publicacion": {"dtype": "string"},
13
- "fecha_limite": {"dtype": "string"},
14
- "titulo": {"dtype": "string"},
15
- "empresa": {"dtype": "string"},
16
- "ocupacion": {"dtype": "string"},
17
- "descripcion": {"dtype": "string"},
18
- "pais": {"dtype": "string"},
19
- "region": {"dtype": "string"},
20
- "tipo_contrato": {"dtype": "string"},
21
- },
 
 
22
  supervised_keys=None,
23
  )
24
 
25
  def _split_generators(self, dl_manager):
 
26
  data_path = dl_manager.download_and_extract("data/job_offers.csv")
27
  return [
28
- SplitGenerator(name=Split.TRAIN, gen_kwargs={"filepath": data_path}),
 
 
 
29
  ]
30
 
31
  def _generate_examples(self, filepath):
32
  with open(filepath, encoding="utf-8") as f:
33
- reader = csv.DictReader(f, delimiter=";")
34
  for idx, row in enumerate(reader):
35
  yield idx, {
36
- "url": row["url"],
37
- "fecha_publicacion": row["fecha_publicacion"],
38
- "fecha_limite": row["fecha_limite"],
39
- "titulo": row["titulo"],
40
- "empresa": row["empresa"],
41
- "ocupacion": row["ocupacion"],
42
- "descripcion": row["descripcion"],
43
- "pais": row["pais"],
44
- "region": row["region"],
45
- "tipo_contrato": row["tipo_contrato"],
46
  }
 
1
  import csv
2
+ import datasets
3
 
4
+ class JobOffersESP(datasets.GeneratorBasedBuilder):
5
+ VERSION = datasets.Version("1.0.0")
6
 
7
  def _info(self):
8
+ return datasets.DatasetInfo(
9
  description="Dataset de ofertas laborales en español extraídas de EURES y fuentes autonómicas.",
10
+ features=datasets.Features(
11
+ {
12
+ "url": datasets.Value("string"),
13
+ "fecha_publicacion": datasets.Value("string"),
14
+ "fecha_limite": datasets.Value("string"),
15
+ "titulo": datasets.Value("string"),
16
+ "empresa": datasets.Value("string"),
17
+ "ocupacion": datasets.Value("string"),
18
+ "descripcion": datasets.Value("string"),
19
+ "pais": datasets.Value("string"),
20
+ "region": datasets.Value("string"),
21
+ "tipo_contrato": datasets.Value("string"),
22
+ }
23
+ ),
24
  supervised_keys=None,
25
  )
26
 
27
  def _split_generators(self, dl_manager):
28
+ # Si el archivo está en tu repo local, no uses download_and_extract
29
  data_path = dl_manager.download_and_extract("data/job_offers.csv")
30
  return [
31
+ datasets.SplitGenerator(
32
+ name=datasets.Split.TRAIN,
33
+ gen_kwargs={"filepath": data_path},
34
+ ),
35
  ]
36
 
37
  def _generate_examples(self, filepath):
38
  with open(filepath, encoding="utf-8") as f:
39
+ reader = csv.DictReader(f, delimiter=";", quotechar='"')
40
  for idx, row in enumerate(reader):
41
  yield idx, {
42
+ "url": row.get("url", ""),
43
+ "fecha_publicacion": row.get("fecha_publicacion", ""),
44
+ "fecha_limite": row.get("fecha_limite", ""),
45
+ "titulo": row.get("titulo", ""),
46
+ "empresa": row.get("empresa", ""),
47
+ "ocupacion": row.get("ocupacion", ""),
48
+ "descripcion": row.get("descripcion", ""),
49
+ "pais": row.get("pais", ""),
50
+ "region": row.get("region", ""),
51
+ "tipo_contrato": row.get("tipo_contrato", ""),
52
  }