Upload 3 files
Browse files- README.md +15 -14
- app.py +37 -0
- requirements.txt +2 -0
README.md
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
-
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
-
sdk: gradio
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
1 |
+
---
|
2 |
+
title: "An谩lisis de Sentimientos"
|
3 |
+
emoji: "馃檪"
|
4 |
+
colorFrom: "blue"
|
5 |
+
colorTo: "purple"
|
6 |
+
sdk: "gradio"
|
7 |
+
|
8 |
+
models:
|
9 |
+
- "cardiffnlp/twitter-xlm-roberta-base-sentiment"
|
10 |
+
tags:
|
11 |
+
- "sentiment-analysis"
|
12 |
+
- "gradio"
|
13 |
+
- "nlp"
|
14 |
+
- "transformers"
|
15 |
+
---
|
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
classifier = pipeline("sentiment-analysis", model="cardiffnlp/twitter-xlm-roberta-base-sentiment")
|
5 |
+
|
6 |
+
def sentiment_analysis(message, history):
|
7 |
+
"""
|
8 |
+
Funci贸n para analizar el sentimiento de un mensaje.
|
9 |
+
Retorna la etiqueta de sentimiento con su probabilidad.
|
10 |
+
"""
|
11 |
+
result = classifier(message)
|
12 |
+
return f"Sentimiento : {result[0]['label']} (Probabilidad: {result[0]['score']:.2f})"
|
13 |
+
|
14 |
+
with gr.Blocks() as demo:
|
15 |
+
gr.Markdown("""
|
16 |
+
# An谩lisis de Sentimientos
|
17 |
+
Esta aplicaci贸n utiliza un modelo de Machine Learning para analizar el sentimiento de los mensajes ingresados.
|
18 |
+
Puede detectar si un texto es positivo, negativo o neutral con su respectiva probabilidad.
|
19 |
+
""")
|
20 |
+
|
21 |
+
chat = gr.ChatInterface(sentiment_analysis, type="messages")
|
22 |
+
|
23 |
+
gr.Markdown("""
|
24 |
+
---
|
25 |
+
### Con茅ctate conmigo:
|
26 |
+
[](https://www.instagram.com/srjosueaaron/)
|
27 |
+
[](https://www.tiktok.com/@srjosueaaron)
|
28 |
+
[](https://www.youtube.com/@srjosueaaron)
|
29 |
+
|
30 |
+
---
|
31 |
+
Demostraci贸n de An谩lisis de Sentimientos usando el modelo de [CardiffNLP](https://huggingface.co/cardiffnlp/twitter-xlm-roberta-base-sentiment).
|
32 |
+
|
33 |
+
Desarrollado con 鉂わ笍 por [@srjosueaaron](https://www.instagram.com/srjosueaaron/).
|
34 |
+
""")
|
35 |
+
|
36 |
+
if __name__ == "__main__":
|
37 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers[sentencepiece]
|