nixonthe commited on
Commit
83db066
·
1 Parent(s): 46ecd21

Initial commit

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. requirements.txt +87 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import gradio as gr
3
+ from textblob import TextBlob
4
+
5
+ def sentiment_analysis(text: str) -> str:
6
+ """
7
+ Analyze the sentiment of the given text.
8
+
9
+ Args:
10
+ text (str): The text to analyze
11
+
12
+ Returns:
13
+ str: A JSON string containing polarity, subjectivity, and assessment
14
+ """
15
+ blob = TextBlob(text)
16
+ sentiment = blob.sentiment
17
+
18
+ result = {
19
+ "polarity": round(sentiment.polarity, 2), # -1 (negative) to 1 (positive)
20
+ "subjectivity": round(sentiment.subjectivity, 2), # 0 (objective) to 1 (subjective)
21
+ "assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
22
+ }
23
+
24
+ return json.dumps(result)
25
+
26
+ # Create the Gradio interface
27
+ demo = gr.Interface(
28
+ fn=sentiment_analysis,
29
+ inputs=gr.Textbox(placeholder="Enter text to analyze..."),
30
+ outputs=gr.Textbox(), # Changed from gr.JSON() to gr.Textbox()
31
+ title="Text Sentiment Analysis",
32
+ description="Analyze the sentiment of text using TextBlob"
33
+ )
34
+
35
+ # Launch the interface and MCP server
36
+ if __name__ == "__main__":
37
+ demo.launch(mcp_server=True)
requirements.txt ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==24.1.0
2
+ annotated-types==0.7.0
3
+ anyio==4.9.0
4
+ asttokens==3.0.0
5
+ certifi==2025.4.26
6
+ charset-normalizer==3.4.2
7
+ click==8.2.1
8
+ colorama==0.4.6
9
+ comm==0.2.2
10
+ debugpy==1.8.14
11
+ decorator==5.2.1
12
+ executing==2.2.0
13
+ fastapi==0.115.12
14
+ ffmpy==0.6.0
15
+ filelock==3.18.0
16
+ fsspec==2025.5.1
17
+ gradio==5.33.0
18
+ gradio_client==1.10.2
19
+ groovy==0.1.2
20
+ h11==0.16.0
21
+ httpcore==1.0.9
22
+ httpx==0.28.1
23
+ httpx-sse==0.4.0
24
+ huggingface-hub==0.32.4
25
+ idna==3.10
26
+ ipykernel==6.29.5
27
+ ipython==9.3.0
28
+ ipython_pygments_lexers==1.1.1
29
+ jedi==0.19.2
30
+ Jinja2==3.1.6
31
+ joblib==1.5.1
32
+ jupyter_client==8.6.3
33
+ jupyter_core==5.8.1
34
+ markdown-it-py==3.0.0
35
+ MarkupSafe==3.0.2
36
+ matplotlib-inline==0.1.7
37
+ mcp==1.9.0
38
+ mdurl==0.1.2
39
+ nest-asyncio==1.6.0
40
+ nltk==3.9.1
41
+ numpy==2.3.0
42
+ orjson==3.10.18
43
+ packaging==25.0
44
+ pandas==2.3.0
45
+ parso==0.8.4
46
+ pillow==11.2.1
47
+ platformdirs==4.3.8
48
+ prompt_toolkit==3.0.51
49
+ psutil==7.0.0
50
+ pure_eval==0.2.3
51
+ pydantic==2.11.5
52
+ pydantic-settings==2.9.1
53
+ pydantic_core==2.33.2
54
+ pydub==0.25.1
55
+ Pygments==2.19.1
56
+ python-dateutil==2.9.0.post0
57
+ python-dotenv==1.1.0
58
+ python-multipart==0.0.20
59
+ pytz==2025.2
60
+ pywin32==310
61
+ PyYAML==6.0.2
62
+ pyzmq==26.4.0
63
+ regex==2024.11.6
64
+ requests==2.32.3
65
+ rich==14.0.0
66
+ ruff==0.11.13
67
+ safehttpx==0.1.6
68
+ semantic-version==2.10.0
69
+ shellingham==1.5.4
70
+ six==1.17.0
71
+ sniffio==1.3.1
72
+ sse-starlette==2.3.6
73
+ stack-data==0.6.3
74
+ starlette==0.46.2
75
+ textblob==0.19.0
76
+ tomlkit==0.13.3
77
+ tornado==6.5.1
78
+ tqdm==4.67.1
79
+ traitlets==5.14.3
80
+ typer==0.16.0
81
+ typing-inspection==0.4.1
82
+ typing_extensions==4.14.0
83
+ tzdata==2025.2
84
+ urllib3==2.4.0
85
+ uvicorn==0.34.3
86
+ wcwidth==0.2.13
87
+ websockets==15.0.1