Sharathhebbar24 commited on
Commit
8aba63b
·
verified ·
1 Parent(s): 8d9796a

Upload 2 files

Browse files
Files changed (2) hide show
  1. main.py +25 -0
  2. requirements.txt +2 -0
main.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from textblob import TextBlob
3
+
4
+ def sentiment_analysis(text: str) -> dict:
5
+ blob = TextBlob(text)
6
+ sentiment = blob.sentiment
7
+
8
+ return {
9
+ "polarity": round(sentiment.polarity, 2),
10
+ "subjectivity": round(sentiment.subjectivity, 2),
11
+ "assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
12
+ }
13
+
14
+
15
+
16
+ demo = gr.Interface(
17
+ fn=sentiment_analysis,
18
+ inputs=gr.Textbox(placeholder="Enter the Text to analyze"),
19
+ outputs=gr.JSON(),
20
+ title="Sentiment Analysis",
21
+ description="Analyse the sentiment of text using TextBlob"
22
+ )
23
+
24
+ if __name__ == "__main__":
25
+ demo.launch(mcp_server=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio[mcp]
2
+ textblob