Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,18 +8,26 @@ def load_model(selected_model):
|
|
8 |
return loaded_model
|
9 |
|
10 |
encoder = {
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
classifier = pipeline(task="zero-shot-classification", model="facebook/bart-large-mnli")
|
|
|
17 |
def analyze_sentiment(text):
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
demo = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text", title="Sentiment Analysis")
|
25 |
demo.launch(share=True)
|
|
|
|
8 |
return loaded_model
|
9 |
|
10 |
encoder = {
|
11 |
+
'negative': "Negativo",
|
12 |
+
'neutral': "Neutro",
|
13 |
+
'positive': "Positivo"
|
14 |
+
}
|
15 |
|
16 |
classifier = pipeline(task="zero-shot-classification", model="facebook/bart-large-mnli")
|
17 |
+
|
18 |
def analyze_sentiment(text):
|
19 |
+
results = classifier(text, ["positive", "negative", "neutral"], multi_label=True)
|
20 |
+
mx = max(results['scores'])
|
21 |
+
ind = results['scores'].index(mx)
|
22 |
+
result = results['labels'][ind]
|
23 |
+
return encoder[result]
|
24 |
+
|
25 |
+
demo = gr.Interface(
|
26 |
+
fn=analyze_sentiment,
|
27 |
+
inputs="text",
|
28 |
+
outputs="text",
|
29 |
+
title="Análisis de Sentimientos"
|
30 |
+
)
|
31 |
|
|
|
32 |
demo.launch(share=True)
|
33 |
+
|