Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,41 +1,20 @@
|
|
1 |
-
#
|
2 |
from transformers import pipeline
|
3 |
import gradio as gr
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
def
|
10 |
-
return str(
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
input = gr.Textbox(label="Texto a clasificar")
|
16 |
-
btn_clasificar = gr.Button(value="Clasificar")
|
17 |
-
with gr.Column():
|
18 |
-
output = gr.Textbox(label="Sentimiento")
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
if sentiment == "POS":
|
26 |
-
sentiment_label = "Positivo"
|
27 |
-
elif sentiment == "NEU":
|
28 |
-
sentiment_label = "Neutro"
|
29 |
-
elif sentiment == "NEG":
|
30 |
-
sentiment_label = "Negativo"
|
31 |
-
else:
|
32 |
-
sentiment_label = "Desconocido"
|
33 |
-
|
34 |
-
output.value = sentiment_label
|
35 |
-
|
36 |
-
btn_clasificar.click(clasificador, inputs=input, outputs=output)
|
37 |
-
examples = gr.Examples(examples=['Estoy feliz 馃 de mostrarles un toolkit para An谩lisis de Sentimientos y otras tareas de SocialNLP',
|
38 |
-
'Espero que no lo odien.',
|
39 |
-
'Lo odiamos.'], inputs=[input])
|
40 |
-
|
41 |
-
demo.launch()
|
|
|
1 |
+
# Import libraries
|
2 |
from transformers import pipeline
|
3 |
import gradio as gr
|
4 |
|
5 |
+
# Initialize Sentiment Classification Model
|
6 |
+
model_name = 'pysentimiento/robertuito-sentiment-analysis'
|
7 |
+
classifier = pipeline("text-classification", model=model_name)
|
8 |
|
9 |
+
def classify_text(text):
|
10 |
+
return str(classifier(text)[0]['label'])
|
11 |
|
12 |
+
# Create Gradio Interface
|
13 |
+
input_text = gr.inputs.Textbox(label="Texto a clasificar")
|
14 |
+
output_text = gr.outputs.Textbox(label="Sentimiento")
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
gr.Interface(fn=classify_text, inputs=input_text, outputs=output_text, examples=[
|
17 |
+
['Estoy feliz 馃 de mostrarles un toolkit para An谩lisis de Sentimientos y otras tareas de SocialNLP'],
|
18 |
+
['Espero que no lo odien.'],
|
19 |
+
['Lo odiamos.']
|
20 |
+
]).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|