Rhaosody commited on
Commit
04e44e1
·
verified ·
1 Parent(s): 8b3426d

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +33 -19
  2. goemotions_es_demo_subset_fixed.json +0 -0
  3. requirements.txt +1 -0
app.py CHANGED
@@ -1,29 +1,43 @@
1
  import gradio as gr
2
  import json
 
3
 
4
- # Cargar subset de demo
5
- with open("goemotions_es_demo_subset.json", "r", encoding="utf-8") as f:
6
  data = json.load(f)
7
 
8
- def analizar_texto(texto):
9
- for entrada in data:
10
- if entrada["text_corregido"].strip().lower() == texto.strip().lower():
11
- meta = entrada["metadatos"]
12
- return {
13
- "Texto": entrada["text_corregido"],
14
- "Intención": meta.get("intent", "N/A"),
15
- "Tema": meta.get("context_topic", "N/A"),
16
- "Emoción manual": meta.get("emotion_manual", "N/A"),
17
- "Nivel de energía": meta.get("energy_level", "N/A")
18
- }
19
- return {"Resultado": "Frase no encontrada en el demo."}
 
20
 
 
21
  demo = gr.Interface(
22
- fn=analizar_texto,
23
- inputs=gr.Textbox(label="Ingresa una frase del demo en español"),
24
- outputs="json",
25
- title="GoEmotions_ES Demo",
26
- description="Ingresa una frase para ver su análisis emocional según el dataset traducido de GoEmotions al español."
 
 
 
 
 
 
 
 
 
 
 
27
  )
28
 
29
  demo.launch()
 
1
  import gradio as gr
2
  import json
3
+ import random
4
 
5
+ # Cargar el dataset demo
6
+ with open("goemotions_es_demo_subset_fixed.json", "r", encoding="utf-8") as f:
7
  data = json.load(f)
8
 
9
+ # Función para mostrar una muestra aleatoria
10
+ def mostrar_muestra():
11
+ ejemplo = random.choice(data)
12
+ return (
13
+ ejemplo["persona"],
14
+ ejemplo["contexto_usuario"],
15
+ ejemplo["respuesta_asistente"],
16
+ ejemplo["emotion"],
17
+ ejemplo["intencion"],
18
+ ejemplo["tono"],
19
+ ejemplo["energia"],
20
+ " Coherente" if ejemplo["coherente"] else "⚠️ Incoherente"
21
+ )
22
 
23
+ # Interfaz de salida
24
  demo = gr.Interface(
25
+ fn=mostrar_muestra,
26
+ inputs=[],
27
+ outputs=[
28
+ gr.Textbox(label="🧠 Persona (contexto)"),
29
+ gr.Textbox(label="💬 Usuario dice"),
30
+ gr.Textbox(label="🤖 Asistente responde"),
31
+ gr.Textbox(label="🎭 Emoción principal"),
32
+ gr.Textbox(label="🎯 Intención"),
33
+ gr.Textbox(label="🎙️ Tono conversacional"),
34
+ gr.Number(label="⚡ Nivel de energía"),
35
+ gr.Textbox(label="📌 Coherencia")
36
+ ],
37
+ title="GoEmotions-ES Demo (Lucio-Rhapsody)",
38
+ description="Explora muestras aleatorias del dataset emocional en español curado por Lucio-Rhapsody. Este espacio no utiliza un modelo, sino el dataset demo.",
39
+ allow_flagging="never",
40
+ live=False
41
  )
42
 
43
  demo.launch()
goemotions_es_demo_subset_fixed.json ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio>=3.0