File size: 1,689 Bytes
8af3323
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from transformers import pipeline
import gradio as gr

classifier = pipeline("sentiment-analysis", model="cardiffnlp/twitter-xlm-roberta-base-sentiment")

def sentiment_analysis(message, history):
    """

    Funci贸n para analizar el sentimiento de un mensaje.

    Retorna la etiqueta de sentimiento con su probabilidad.

    """
    result = classifier(message)
    return f"Sentimiento : {result[0]['label']} (Probabilidad: {result[0]['score']:.2f})"

with gr.Blocks() as demo:
    gr.Markdown("""

    # An谩lisis de Sentimientos

    Esta aplicaci贸n utiliza un modelo de Machine Learning para analizar el sentimiento de los mensajes ingresados. 

    Puede detectar si un texto es positivo, negativo o neutral con su respectiva probabilidad.

    """)
    
    chat = gr.ChatInterface(sentiment_analysis, type="messages")
    
    gr.Markdown("""

    ---

    ### Con茅ctate conmigo:

    [![Instagram](https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white)](https://www.instagram.com/srjosueaaron/)

    [![TikTok](https://img.shields.io/badge/TikTok-000000?style=for-the-badge&logo=tiktok&logoColor=white)](https://www.tiktok.com/@srjosueaaron)

    [![YouTube](https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@srjosueaaron)

    

    ---

    Demostraci贸n de An谩lisis de Sentimientos usando el modelo de [CardiffNLP](https://huggingface.co/cardiffnlp/twitter-xlm-roberta-base-sentiment).

    

    Desarrollado con 鉂わ笍 por [@srjosueaaron](https://www.instagram.com/srjosueaaron/).

    """)

if __name__ == "__main__":
    demo.launch()