Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,12 +5,20 @@ from transformers import pipeline
|
|
5 |
classifier = pipeline(task="zero-shot-classification", model="facebook/bart-large-mnli")
|
6 |
|
7 |
def analyze_sentiment(text):
|
8 |
-
results = classifier(text, ["
|
9 |
mx = max(results['scores'])
|
10 |
ind = results['scores'].index(mx)
|
11 |
-
result = results['labels'][ind]
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Configuraci贸n de la interfaz de Gradio
|
16 |
demo = gr.Interface(
|
|
|
5 |
classifier = pipeline(task="zero-shot-classification", model="facebook/bart-large-mnli")
|
6 |
|
7 |
def analyze_sentiment(text):
|
8 |
+
results = classifier(text, ["positive", "negative", "neutral"], multi_label=True)
|
9 |
mx = max(results['scores'])
|
10 |
ind = results['scores'].index(mx)
|
11 |
+
result = results['labels'][ind]
|
12 |
|
13 |
+
# Traducci贸n de etiquetas al espa帽ol
|
14 |
+
if result == "positive":
|
15 |
+
sentiment = "Positivo"
|
16 |
+
elif result == "negative":
|
17 |
+
sentiment = "Negativo"
|
18 |
+
else:
|
19 |
+
sentiment = "Neutro"
|
20 |
+
|
21 |
+
return sentiment
|
22 |
|
23 |
# Configuraci贸n de la interfaz de Gradio
|
24 |
demo = gr.Interface(
|