Jhoeel commited on
Commit
5927b5a
1 Parent(s): b5bbbbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -1,12 +1,22 @@
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
  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
- # Create Gradio Interface
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