Update app.py
Browse files"""
Modalidades y Tareas Disponibles:
- NLP: Clasificaci贸n de texto, Generaci贸n de texto, Traducci贸n, Resumen
- Audio: Reconocimiento de voz, Clasificaci贸n de audio, Separaci贸n de fuentes
- Educaci贸n: Ense帽anza virtual, Capacitaci贸n did谩ctica, Desarrollo de habilidades <button class="citation-flag" data-index="7">
- Trabajo Remoto: Gesti贸n de equipos remotos, Productividad digital, Colaboraci贸n en l铆nea <button class="citation-flag" data-index="10">
"""
app.py
CHANGED
|
@@ -1,17 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from datasets import load_dataset
|
| 3 |
import requests
|
|
|
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Funci贸n para actualizar las tareas seg煤n las modalidades seleccionadas
|
| 17 |
def actualizar_tareas(modalidades_seleccionadas):
|
|
@@ -26,10 +31,13 @@ def actualizar_tareas(modalidades_seleccionadas):
|
|
| 26 |
def generar_encabezado(modalidades_seleccionadas, tareas_seleccionadas):
|
| 27 |
if not modalidades_seleccionadas or not tareas_seleccionadas:
|
| 28 |
raise ValueError("Debes seleccionar al menos una modalidad y una tarea.")
|
|
|
|
| 29 |
columnas = ["id"] # A帽adimos 'id' como primer elemento
|
| 30 |
for modalidad in modalidades_seleccionadas:
|
| 31 |
columnas.append(f"{modalidad.lower()}_input")
|
| 32 |
columnas.append(f"{modalidad.lower()}_output")
|
|
|
|
|
|
|
| 33 |
for tarea in tareas_seleccionadas:
|
| 34 |
columnas.append(f"{tarea.lower().replace(' ', '_')}_label")
|
| 35 |
return ",".join(columnas)
|
|
@@ -48,6 +56,9 @@ def buscar_datasets(modalidades_seleccionadas, tareas_seleccionadas, filtro_tama
|
|
| 48 |
continue
|
| 49 |
if filtro_licencia and dataset.get("license") != filtro_licencia:
|
| 50 |
continue
|
|
|
|
|
|
|
|
|
|
| 51 |
resultados.append(f"- {dataset['id']}: {dataset['description']}")
|
| 52 |
return "\n".join(resultados)
|
| 53 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from datasets import load_dataset
|
| 3 |
import requests
|
| 4 |
+
import json
|
| 5 |
|
| 6 |
+
# Cargar modalidades y tareas desde un archivo JSON
|
| 7 |
+
with open("modalidades_tareas.json", "r") as file:
|
| 8 |
+
MODALIDAD_TAREAS = json.load(file)
|
| 9 |
+
|
| 10 |
+
def validar_modalidades_tareas(modalidades_tareas):
|
| 11 |
+
for modalidad, tareas in modalidades_tareas.items():
|
| 12 |
+
if not isinstance(modalidad, str) or not isinstance(tareas, list):
|
| 13 |
+
raise ValueError(f"Formato incorrecto para la modalidad: {modalidad}")
|
| 14 |
+
for tarea in tareas:
|
| 15 |
+
if not isinstance(tarea, str):
|
| 16 |
+
raise ValueError(f"Formato incorrecto para la tarea: {tarea} en la modalidad {modalidad}")
|
| 17 |
+
|
| 18 |
+
# Validar el diccionario
|
| 19 |
+
validar_modalidades_tareas(MODALIDAD_TAREAS)
|
| 20 |
|
| 21 |
# Funci贸n para actualizar las tareas seg煤n las modalidades seleccionadas
|
| 22 |
def actualizar_tareas(modalidades_seleccionadas):
|
|
|
|
| 31 |
def generar_encabezado(modalidades_seleccionadas, tareas_seleccionadas):
|
| 32 |
if not modalidades_seleccionadas or not tareas_seleccionadas:
|
| 33 |
raise ValueError("Debes seleccionar al menos una modalidad y una tarea.")
|
| 34 |
+
|
| 35 |
columnas = ["id"] # A帽adimos 'id' como primer elemento
|
| 36 |
for modalidad in modalidades_seleccionadas:
|
| 37 |
columnas.append(f"{modalidad.lower()}_input")
|
| 38 |
columnas.append(f"{modalidad.lower()}_output")
|
| 39 |
+
if modalidad == "Educaci贸n": # Caso especial para una nueva modalidad
|
| 40 |
+
columnas.append("metodolog铆a_educativa")
|
| 41 |
for tarea in tareas_seleccionadas:
|
| 42 |
columnas.append(f"{tarea.lower().replace(' ', '_')}_label")
|
| 43 |
return ",".join(columnas)
|
|
|
|
| 56 |
continue
|
| 57 |
if filtro_licencia and dataset.get("license") != filtro_licencia:
|
| 58 |
continue
|
| 59 |
+
# Filtrar por modalidad espec铆fica
|
| 60 |
+
if "Educaci贸n" in modalidades_seleccionadas and "educaci贸n" not in dataset["tags"]:
|
| 61 |
+
continue
|
| 62 |
resultados.append(f"- {dataset['id']}: {dataset['description']}")
|
| 63 |
return "\n".join(resultados)
|
| 64 |
|