Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,22 @@
|
|
| 1 |
-
#
|
| 2 |
from transformers import pipeline
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
#
|
| 6 |
model_name = 'pysentimiento/robertuito-sentiment-analysis'
|
| 7 |
classifier = pipeline("text-classification", model=model_name)
|
| 8 |
|
| 9 |
def classify_text(text):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
result = classifier(text)[0]['label']
|
| 11 |
if result == "POS":
|
| 12 |
return "Positivo"
|
|
@@ -15,7 +25,7 @@ def classify_text(text):
|
|
| 15 |
else:
|
| 16 |
return "Neutro"
|
| 17 |
|
| 18 |
-
#
|
| 19 |
input_text = gr.inputs.Textbox(label="Texto a clasificar")
|
| 20 |
output_text = gr.outputs.Textbox(label="Sentimiento")
|
| 21 |
|
|
|
|
| 1 |
+
# Importa librerias
|
| 2 |
from transformers import pipeline
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
# Inicializa Modelo de Clasificaci贸n de Sentimientos
|
| 6 |
model_name = 'pysentimiento/robertuito-sentiment-analysis'
|
| 7 |
classifier = pipeline("text-classification", model=model_name)
|
| 8 |
|
| 9 |
def classify_text(text):
|
| 10 |
+
"""
|
| 11 |
+
Clasifica un texto como positivo, negativo o neutro utilizando un clasificador.
|
| 12 |
+
|
| 13 |
+
Args:
|
| 14 |
+
text (str): El texto a clasificar.
|
| 15 |
+
|
| 16 |
+
Returns:
|
| 17 |
+
str: La clasificaci贸n del texto, que puede ser "Positivo", "Negativo" o "Neutro".
|
| 18 |
+
|
| 19 |
+
"""
|
| 20 |
result = classifier(text)[0]['label']
|
| 21 |
if result == "POS":
|
| 22 |
return "Positivo"
|
|
|
|
| 25 |
else:
|
| 26 |
return "Neutro"
|
| 27 |
|
| 28 |
+
# Crea Interfaz Gradio
|
| 29 |
input_text = gr.inputs.Textbox(label="Texto a clasificar")
|
| 30 |
output_text = gr.outputs.Textbox(label="Sentimiento")
|
| 31 |
|