root commited on
Commit
b90cf84
·
1 Parent(s): 5452e1e

Iniciando a aplicação

Browse files
Files changed (4) hide show
  1. .gitattributes +0 -0
  2. README.md +0 -0
  3. app.py +42 -0
  4. requirements.txt +2 -0
.gitattributes CHANGED
File without changes
README.md CHANGED
File without changes
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ #
3
+
4
+ import gradio as gr
5
+ from textblob import TextBlob
6
+
7
+ def sentiment_analysis(text: str) -> dict:
8
+ """
9
+ Analyze the sentiment of the given text.
10
+
11
+ Args:
12
+ text (str): The text to analyze
13
+
14
+ Returns:
15
+ dict: A dictionary containing polarity, subjectivity, and assessment
16
+ """
17
+ blob = TextBlob(text)
18
+ sentiment = blob.sentiment
19
+
20
+ _polarity = round(sentiment.polarity, 2) # -1 (negative) to 1 (positive)
21
+ _subjectivity = round(sentiment.subjectivity, 2) # 0 (objective) to 1 (subjective)
22
+ _assessment = "positive" if _polarity > 0 else \
23
+ "negative" if _polarity < 0 else "neutral"
24
+
25
+ return {
26
+ "polarity": _polarity,
27
+ "subjectivity": _subjectivity,
28
+ "assessment": _assessment,
29
+ }
30
+
31
+ # Create the Gradio interface
32
+ demo = gr.Interface(
33
+ fn = sentiment_analysis,
34
+ inputs = gr.Textbox(placeholder="Enter text to analyze..."),
35
+ outputs = gr.JSON(),
36
+ title = "Text Sentiment Analysis",
37
+ description = "Analyze the sentiment of text using TextBlob"
38
+ )
39
+
40
+ # Launch the interface and MCP server
41
+ if __name__ == "__main__":
42
+ demo.launch(mcp_server=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio[mcp]
2
+ textblob