Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ classifier = pipeline(task="zero-shot-classification", model="facebook/bart-larg
|
|
| 8 |
# Funci贸n para analizar los sentimientos de una lista de textos
|
| 9 |
def analyze_sentiments(texts):
|
| 10 |
if not texts:
|
| 11 |
-
return 0.0, 0.0, 0.0 # Manejar el caso donde no hay textos para analizar
|
| 12 |
|
| 13 |
positive, negative, neutral = 0, 0, 0
|
| 14 |
for text in texts:
|
|
@@ -23,10 +23,10 @@ def analyze_sentiments(texts):
|
|
| 23 |
else:
|
| 24 |
neutral += 1
|
| 25 |
total = len(texts)
|
| 26 |
-
positive_percent = (positive / total) * 100
|
| 27 |
-
negative_percent = (negative / total) * 100
|
| 28 |
-
neutral_percent = (neutral / total) * 100
|
| 29 |
-
return positive_percent, negative_percent, neutral_percent
|
| 30 |
|
| 31 |
# Funci贸n para cargar el archivo CSV y analizar los primeros 100 comentarios
|
| 32 |
def analyze_sentiment_from_csv(file):
|
|
@@ -51,7 +51,8 @@ demo = gr.Interface(
|
|
| 51 |
gr.Textbox(label="Porcentaje Neutro")
|
| 52 |
],
|
| 53 |
title="Analizador de Sentimientos V.2",
|
| 54 |
-
|
| 55 |
)
|
| 56 |
|
| 57 |
demo.launch(share=True)
|
|
|
|
|
|
| 8 |
# Funci贸n para analizar los sentimientos de una lista de textos
|
| 9 |
def analyze_sentiments(texts):
|
| 10 |
if not texts:
|
| 11 |
+
return "0.0%", "0.0%", "0.0%" # Manejar el caso donde no hay textos para analizar
|
| 12 |
|
| 13 |
positive, negative, neutral = 0, 0, 0
|
| 14 |
for text in texts:
|
|
|
|
| 23 |
else:
|
| 24 |
neutral += 1
|
| 25 |
total = len(texts)
|
| 26 |
+
positive_percent = round((positive / total) * 100, 1)
|
| 27 |
+
negative_percent = round((negative / total) * 100, 1)
|
| 28 |
+
neutral_percent = round((neutral / total) * 100, 1)
|
| 29 |
+
return f"{positive_percent}%", f"{negative_percent}%", f"{neutral_percent}%"
|
| 30 |
|
| 31 |
# Funci贸n para cargar el archivo CSV y analizar los primeros 100 comentarios
|
| 32 |
def analyze_sentiment_from_csv(file):
|
|
|
|
| 51 |
gr.Textbox(label="Porcentaje Neutro")
|
| 52 |
],
|
| 53 |
title="Analizador de Sentimientos V.2",
|
| 54 |
+
description="Porcentaje de comentarios positivos, negativos y neutrales"
|
| 55 |
)
|
| 56 |
|
| 57 |
demo.launch(share=True)
|
| 58 |
+
|