Samuel Thomas commited on
Commit
f7395d8
·
1 Parent(s): 1f29c29

initial commit

Browse files
Files changed (4) hide show
  1. .gitignore +290 -0
  2. README.md +2 -0
  3. app.py +37 -0
  4. requirements.txt +18 -0
.gitignore ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be added to the global gitignore or merged into this project gitignore. For a PyCharm
158
+ # project, it is also recommended to add the following directories to the gitignore:
159
+ # .idea/
160
+ .idea/
161
+ *.iws
162
+ *.iml
163
+ *.ipr
164
+
165
+ # Visual Studio Code
166
+ .vscode/
167
+ *.code-workspace
168
+
169
+ # macOS
170
+ .DS_Store
171
+ .AppleDouble
172
+ .LSOverride
173
+
174
+ # Icon must end with two \r
175
+ Icon
176
+
177
+ # Thumbnails
178
+ ._*
179
+
180
+ # Files that might appear in the root of a volume
181
+ .DocumentRevisions-V100
182
+ .fseventsd
183
+ .Spotlight-V100
184
+ .TemporaryItems
185
+ .Trashes
186
+ .VolumeIcon.icns
187
+ .com.apple.timemachine.donotpresent
188
+
189
+ # Directories potentially created on remote AFP share
190
+ .AppleDB
191
+ .AppleDesktop
192
+ Network Trash Folder
193
+ Temporary Items
194
+ .apdisk
195
+
196
+ # Windows
197
+ Thumbs.db
198
+ Thumbs.db:encryptable
199
+ ehthumbs.db
200
+ ehthumbs_vista.db
201
+ *.tmp
202
+ *.temp
203
+
204
+ # Dump file
205
+ *.stackdump
206
+
207
+ # Folder config file
208
+ [Dd]esktop.ini
209
+
210
+ # Recycle Bin used on file shares
211
+ $RECYCLE.BIN/
212
+
213
+ # Windows Installer files
214
+ *.cab
215
+ *.msi
216
+ *.msix
217
+ *.msm
218
+ *.msp
219
+
220
+ # Windows shortcuts
221
+ *.lnk
222
+
223
+ # Linux
224
+ *~
225
+
226
+ # temporary files which can be created if a process still has a handle open of a deleted file
227
+ .fuse_hidden*
228
+
229
+ # KDE directory preferences
230
+ .directory
231
+
232
+ # Linux trash folder which might appear on any partition or disk
233
+ .Trash-*
234
+
235
+ # .nfs files are created when an open file is removed but is still being accessed
236
+ .nfs*
237
+
238
+ # Gradio specific
239
+ gradio_cached_examples/
240
+ gradio.db
241
+ flagged/
242
+
243
+ # MCP specific
244
+ *.mcp
245
+ mcp_logs/
246
+
247
+ # Local configuration files
248
+ config.local.json
249
+ settings.local.json
250
+ .env.local
251
+
252
+ # Log files
253
+ *.log
254
+ logs/
255
+
256
+ # Temporary files
257
+ tmp/
258
+ temp/
259
+ *.swp
260
+ *.swo
261
+ *~
262
+
263
+ # IDE files
264
+ .sublime-project
265
+ .sublime-workspace
266
+
267
+ # Node.js (if using any npm packages)
268
+ node_modules/
269
+ npm-debug.log*
270
+ yarn-debug.log*
271
+ yarn-error.log*
272
+
273
+ # Screenshots and test outputs
274
+ screenshots/
275
+ test_outputs/
276
+ *.png
277
+ *.jpg
278
+ *.jpeg
279
+ *.gif
280
+ *.pdf
281
+
282
+ # API keys and secrets
283
+ .secrets
284
+ secrets.json
285
+ api_keys.txt
286
+
287
+ # Database files
288
+ *.db
289
+ *.sqlite
290
+ *.sqlite3
README.md CHANGED
@@ -10,3 +10,5 @@ pinned: false
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
13
+
14
+ export GRADIO_MCP_SERVER=True
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,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Core dependencies for Sentiment Analysis MCP Server
2
+ gradio[mcp]>=4.44.0
3
+ textblob>=0.17.1
4
+
5
+ # Optional: For better performance and additional features
6
+ # uvicorn>=0.24.0 # ASGI server for production deployment
7
+ # fastapi>=0.104.0 # Web framework (used by Gradio internally)
8
+
9
+ # Optional: For development and testing
10
+ # pytest>=7.4.0 # Testing framework
11
+ # black>=23.0.0 # Code formatting
12
+ # flake8>=6.0.0 # Code linting
13
+
14
+ # Optional: For enhanced NLP capabilities
15
+ # nltk>=3.8.0 # Natural language processing toolkit
16
+ # spacy>=3.7.0 # Advanced NLP
17
+ # vaderSentiment>=3.3.2 # Alternative sentiment analyzer
18
+ # transformers>=4.21.0 # Hugging Face transformers for advanced models