Spaces:
Runtime error
Runtime error
Commit
·
4d9f7f2
1
Parent(s):
63cb1c6
Update app.py, analysis in sidebar
Browse files
app.py
CHANGED
|
@@ -20,11 +20,11 @@ user_needs = pipeline('text-classification', model=model_needs, tokenizer=tokeni
|
|
| 20 |
|
| 21 |
st.title("Plataforma de Diálogos Participativos")
|
| 22 |
|
| 23 |
-
# Text area for input
|
| 24 |
-
text = st.text_area("Añade el texto a evaluar")
|
| 25 |
|
| 26 |
-
# Create columns for buttons
|
| 27 |
-
col1, col2, col3, col4 = st.columns(4)
|
| 28 |
|
| 29 |
# Place each button in a separate column
|
| 30 |
run_sentiment_analysis = col1.button("Evaluar Sentimiento")
|
|
@@ -32,7 +32,7 @@ run_toxicity_analysis = col2.button("Evaluar Toxicidad")
|
|
| 32 |
run_emotion_analysis = col3.button("Evaluar Emoción")
|
| 33 |
run_user_needs_analysis = col4.button("Evaluar Necesidades del Usuario")
|
| 34 |
|
| 35 |
-
# Container for output
|
| 36 |
output_container = st.container()
|
| 37 |
|
| 38 |
# Sentiment analysis
|
|
@@ -43,7 +43,7 @@ if run_sentiment_analysis and text:
|
|
| 43 |
score = round(sentiment_output[0]['score'] * 100, 2)
|
| 44 |
st.markdown(f"**Resultado del análisis de sentimiento:**\n\n- **Etiqueta:** {label}\n- **Confianza:** {score}%")
|
| 45 |
elif run_sentiment_analysis and not text:
|
| 46 |
-
st.warning("Por favor, añade un texto para evaluar el sentimiento.")
|
| 47 |
|
| 48 |
# Toxicity analysis
|
| 49 |
if run_toxicity_analysis and text:
|
|
@@ -53,7 +53,7 @@ if run_toxicity_analysis and text:
|
|
| 53 |
score = round(toxicity_output[0]['score'] * 100, 2)
|
| 54 |
st.markdown(f"**Resultado del análisis de toxicidad:**\n\n- **Etiqueta:** {label}\n- **Confianza:** {score}%")
|
| 55 |
elif run_toxicity_analysis and not text:
|
| 56 |
-
st.warning("Por favor, añade un texto para evaluar la toxicidad.")
|
| 57 |
|
| 58 |
# Emotion analysis
|
| 59 |
if run_emotion_analysis and text:
|
|
@@ -63,7 +63,7 @@ if run_emotion_analysis and text:
|
|
| 63 |
score = round(emotion_output[0]['score'] * 100, 2)
|
| 64 |
st.markdown(f"**Resultado del análisis de emoción:**\n\n- **Etiqueta:** {label}\n- **Confianza:** {score}%")
|
| 65 |
elif run_emotion_analysis and not text:
|
| 66 |
-
st.warning("Por favor, añade un texto para evaluar la emoción.")
|
| 67 |
|
| 68 |
# User needs analysis
|
| 69 |
if run_user_needs_analysis and text:
|
|
@@ -73,4 +73,4 @@ if run_user_needs_analysis and text:
|
|
| 73 |
score = round(needs_output[0]['score'] * 100, 2)
|
| 74 |
st.markdown(f"**Resultado del análisis de necesidades del usuario:**\n\n- **Etiqueta:** {label}\n- **Confianza:** {score}%")
|
| 75 |
elif run_user_needs_analysis and not text:
|
| 76 |
-
st.warning("Por favor, añade un texto para evaluar las necesidades del usuario.")
|
|
|
|
| 20 |
|
| 21 |
st.title("Plataforma de Diálogos Participativos")
|
| 22 |
|
| 23 |
+
# Text area for input in sidebar
|
| 24 |
+
text = st.sidebar.text_area("Añade el texto a evaluar")
|
| 25 |
|
| 26 |
+
# Create columns for buttons in sidebar
|
| 27 |
+
col1, col2, col3, col4 = st.sidebar.columns(4)
|
| 28 |
|
| 29 |
# Place each button in a separate column
|
| 30 |
run_sentiment_analysis = col1.button("Evaluar Sentimiento")
|
|
|
|
| 32 |
run_emotion_analysis = col3.button("Evaluar Emoción")
|
| 33 |
run_user_needs_analysis = col4.button("Evaluar Necesidades del Usuario")
|
| 34 |
|
| 35 |
+
# Container for output in main layout
|
| 36 |
output_container = st.container()
|
| 37 |
|
| 38 |
# Sentiment analysis
|
|
|
|
| 43 |
score = round(sentiment_output[0]['score'] * 100, 2)
|
| 44 |
st.markdown(f"**Resultado del análisis de sentimiento:**\n\n- **Etiqueta:** {label}\n- **Confianza:** {score}%")
|
| 45 |
elif run_sentiment_analysis and not text:
|
| 46 |
+
st.sidebar.warning("Por favor, añade un texto para evaluar el sentimiento.")
|
| 47 |
|
| 48 |
# Toxicity analysis
|
| 49 |
if run_toxicity_analysis and text:
|
|
|
|
| 53 |
score = round(toxicity_output[0]['score'] * 100, 2)
|
| 54 |
st.markdown(f"**Resultado del análisis de toxicidad:**\n\n- **Etiqueta:** {label}\n- **Confianza:** {score}%")
|
| 55 |
elif run_toxicity_analysis and not text:
|
| 56 |
+
st.sidebar.warning("Por favor, añade un texto para evaluar la toxicidad.")
|
| 57 |
|
| 58 |
# Emotion analysis
|
| 59 |
if run_emotion_analysis and text:
|
|
|
|
| 63 |
score = round(emotion_output[0]['score'] * 100, 2)
|
| 64 |
st.markdown(f"**Resultado del análisis de emoción:**\n\n- **Etiqueta:** {label}\n- **Confianza:** {score}%")
|
| 65 |
elif run_emotion_analysis and not text:
|
| 66 |
+
st.sidebar.warning("Por favor, añade un texto para evaluar la emoción.")
|
| 67 |
|
| 68 |
# User needs analysis
|
| 69 |
if run_user_needs_analysis and text:
|
|
|
|
| 73 |
score = round(needs_output[0]['score'] * 100, 2)
|
| 74 |
st.markdown(f"**Resultado del análisis de necesidades del usuario:**\n\n- **Etiqueta:** {label}\n- **Confianza:** {score}%")
|
| 75 |
elif run_user_needs_analysis and not text:
|
| 76 |
+
st.sidebar.warning("Por favor, añade un texto para evaluar las necesidades del usuario.")
|