ReiderMx commited on
Commit
683da6d
1 Parent(s): b770003

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -8,18 +8,26 @@ def load_model(selected_model):
8
  return loaded_model
9
 
10
  encoder = {
11
- 'negative':"a",
12
- 'neutral':"b",
13
- 'positive:"c"
14
- }
15
 
16
  classifier = pipeline(task="zero-shot-classification", model="facebook/bart-large-mnli")
 
17
  def analyze_sentiment(text):
18
- results = classifier(text,["positive","negative",'neutral'],multi_label=True)
19
- mx = max(results['scores'])
20
- ind = results['scores'].index(mx)
21
- result = results['labels'][ind]
22
- return encoder[result]
 
 
 
 
 
 
 
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
+