emmuzoo commited on
Commit
07f701b
·
1 Parent(s): 69363c7

Initial commit

Browse files
Files changed (3) hide show
  1. .gitignore +17 -0
  2. app.py +37 -0
  3. requirements.txt +206 -0
.gitignore ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+
13
+ .gradio
14
+ .python-version
15
+ pyproject.toml
16
+ uv.lock
17
+ help.txt
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,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv pip compile pyproject.toml -o requirements.txt
3
+ aiofiles==24.1.0
4
+ # via gradio
5
+ annotated-doc==0.0.4
6
+ # via fastapi
7
+ annotated-types==0.7.0
8
+ # via pydantic
9
+ anyio==4.11.0
10
+ # via
11
+ # gradio
12
+ # httpx
13
+ # mcp
14
+ # sse-starlette
15
+ # starlette
16
+ attrs==25.4.0
17
+ # via
18
+ # jsonschema
19
+ # referencing
20
+ brotli==1.2.0
21
+ # via gradio
22
+ certifi==2025.11.12
23
+ # via
24
+ # httpcore
25
+ # httpx
26
+ click==8.3.1
27
+ # via
28
+ # nltk
29
+ # typer
30
+ # typer-slim
31
+ # uvicorn
32
+ fastapi==0.122.0
33
+ # via gradio
34
+ ffmpy==1.0.0
35
+ # via gradio
36
+ filelock==3.20.0
37
+ # via huggingface-hub
38
+ fsspec==2025.10.0
39
+ # via
40
+ # gradio-client
41
+ # huggingface-hub
42
+ gradio==5.50.0
43
+ # via mcp-sentiment (pyproject.toml)
44
+ gradio-client==1.14.0
45
+ # via gradio
46
+ groovy==0.1.2
47
+ # via gradio
48
+ h11==0.16.0
49
+ # via
50
+ # httpcore
51
+ # uvicorn
52
+ hf-xet==1.2.0
53
+ # via huggingface-hub
54
+ httpcore==1.0.9
55
+ # via httpx
56
+ httpx==0.28.1
57
+ # via
58
+ # gradio
59
+ # gradio-client
60
+ # huggingface-hub
61
+ # mcp
62
+ # safehttpx
63
+ httpx-sse==0.4.3
64
+ # via mcp
65
+ huggingface-hub==1.1.5
66
+ # via
67
+ # gradio
68
+ # gradio-client
69
+ idna==3.11
70
+ # via
71
+ # anyio
72
+ # httpx
73
+ jinja2==3.1.6
74
+ # via gradio
75
+ joblib==1.5.2
76
+ # via nltk
77
+ jsonschema==4.25.1
78
+ # via mcp
79
+ jsonschema-specifications==2025.9.1
80
+ # via jsonschema
81
+ markdown-it-py==4.0.0
82
+ # via rich
83
+ markupsafe==3.0.3
84
+ # via
85
+ # gradio
86
+ # jinja2
87
+ mcp==1.10.1
88
+ # via gradio
89
+ mdurl==0.1.2
90
+ # via markdown-it-py
91
+ nltk==3.9.2
92
+ # via textblob
93
+ numpy==2.3.5
94
+ # via
95
+ # gradio
96
+ # pandas
97
+ orjson==3.11.4
98
+ # via gradio
99
+ packaging==25.0
100
+ # via
101
+ # gradio
102
+ # gradio-client
103
+ # huggingface-hub
104
+ pandas==2.3.3
105
+ # via gradio
106
+ pillow==11.3.0
107
+ # via gradio
108
+ pydantic==2.12.3
109
+ # via
110
+ # fastapi
111
+ # gradio
112
+ # mcp
113
+ # pydantic-settings
114
+ pydantic-core==2.41.4
115
+ # via pydantic
116
+ pydantic-settings==2.12.0
117
+ # via mcp
118
+ pydub==0.25.1
119
+ # via gradio
120
+ pygments==2.19.2
121
+ # via rich
122
+ python-dateutil==2.9.0.post0
123
+ # via pandas
124
+ python-dotenv==1.2.1
125
+ # via pydantic-settings
126
+ python-multipart==0.0.20
127
+ # via
128
+ # gradio
129
+ # mcp
130
+ pytz==2025.2
131
+ # via pandas
132
+ pyyaml==6.0.3
133
+ # via
134
+ # gradio
135
+ # huggingface-hub
136
+ referencing==0.37.0
137
+ # via
138
+ # jsonschema
139
+ # jsonschema-specifications
140
+ regex==2025.11.3
141
+ # via nltk
142
+ rich==14.2.0
143
+ # via typer
144
+ rpds-py==0.29.0
145
+ # via
146
+ # jsonschema
147
+ # referencing
148
+ ruff==0.14.6
149
+ # via gradio
150
+ safehttpx==0.1.7
151
+ # via gradio
152
+ semantic-version==2.10.0
153
+ # via gradio
154
+ shellingham==1.5.4
155
+ # via
156
+ # huggingface-hub
157
+ # typer
158
+ six==1.17.0
159
+ # via python-dateutil
160
+ sniffio==1.3.1
161
+ # via anyio
162
+ sse-starlette==3.0.3
163
+ # via mcp
164
+ starlette==0.50.0
165
+ # via
166
+ # fastapi
167
+ # gradio
168
+ # mcp
169
+ textblob==0.19.0
170
+ # via mcp-sentiment (pyproject.toml)
171
+ tomlkit==0.13.3
172
+ # via gradio
173
+ tqdm==4.67.1
174
+ # via
175
+ # huggingface-hub
176
+ # nltk
177
+ typer==0.20.0
178
+ # via gradio
179
+ typer-slim==0.20.0
180
+ # via huggingface-hub
181
+ typing-extensions==4.15.0
182
+ # via
183
+ # anyio
184
+ # fastapi
185
+ # gradio
186
+ # gradio-client
187
+ # huggingface-hub
188
+ # pydantic
189
+ # pydantic-core
190
+ # referencing
191
+ # starlette
192
+ # typer
193
+ # typer-slim
194
+ # typing-inspection
195
+ typing-inspection==0.4.2
196
+ # via
197
+ # pydantic
198
+ # pydantic-settings
199
+ tzdata==2025.2
200
+ # via pandas
201
+ uvicorn==0.38.0
202
+ # via
203
+ # gradio
204
+ # mcp
205
+ websockets==15.0.1
206
+ # via gradio-client