thecodemaiden commited on
Commit
0d72569
·
1 Parent(s): 47da114

First MCP server

Browse files
Files changed (3) hide show
  1. .gitignore +3 -0
  2. app.py +34 -0
  3. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ .venv
2
+ __pycache__/
3
+
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from textblob import TextBlob
3
+
4
+ def sentiment_analysis(text):
5
+ """
6
+ Perform sentiment analysis on the input text.
7
+
8
+ Args:
9
+ text (str): The input text to analyze.
10
+
11
+ Returns:
12
+ dict: A dictionary containing the polarity and subjectivity, and the sentiment classification.
13
+ """
14
+ blob = TextBlob(text)
15
+ sentiment = blob.sentiment
16
+ results = {
17
+ "Polarity": sentiment.polarity,
18
+ "Subjectivity": sentiment.subjectivity,
19
+ "Sentiment": "Positive" if sentiment.polarity > 0 else "Negative" if sentiment.polarity < 0 else "Neutral"
20
+ }
21
+ return results
22
+
23
+ demo = gr.Interface(
24
+ fn=sentiment_analysis,
25
+ inputs=gr.Textbox(lines=2, placeholder="Enter text to analyze"),
26
+ outputs=[
27
+ gr.JSON(label="Sentiment Analysis Results"),
28
+ ],
29
+ title="Sentiment Analysis",
30
+ description="Analyze the sentiment of the input text using TextBlob."
31
+ )
32
+
33
+ if __name__ == "__main__":
34
+ demo.launch(mcp_server=True)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio[mcp]~=5.31.0
2
+ textblob~=0.19.0
3
+