Spaces:
Running
Running
Initial commit
Browse files- .gitignore +1 -0
- app.py +34 -0
- requirements.txt +62 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
/venv
|
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from textblob import TextBlob
|
3 |
+
|
4 |
+
def sentiment_analysis(text: str) -> dict:
|
5 |
+
"""
|
6 |
+
Analyze the sentiment of the given text.
|
7 |
+
|
8 |
+
Args:
|
9 |
+
text (str): The text to analyze
|
10 |
+
|
11 |
+
Returns:
|
12 |
+
dict: A dictionary containing polarity, subjectivity, and assessment
|
13 |
+
"""
|
14 |
+
blob = TextBlob(text)
|
15 |
+
sentiment = blob.sentiment
|
16 |
+
|
17 |
+
return {
|
18 |
+
"polarity": round(sentiment.polarity, 2), # -1 (negative) to 1 (positive)
|
19 |
+
"subjectivity": round(sentiment.subjectivity, 2), # 0 (objective) to 1 (subjective)
|
20 |
+
"assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
|
21 |
+
}
|
22 |
+
|
23 |
+
# Create the Gradio interface
|
24 |
+
demo = gr.Interface(
|
25 |
+
fn=sentiment_analysis,
|
26 |
+
inputs=gr.Textbox(placeholder="Enter text to analyze..."),
|
27 |
+
outputs=gr.JSON(),
|
28 |
+
title="Text Sentiment Analysis",
|
29 |
+
description="Analyze the sentiment of text using TextBlob"
|
30 |
+
)
|
31 |
+
|
32 |
+
# Launch the interface and MCP server
|
33 |
+
if __name__ == "__main__":
|
34 |
+
demo.launch(mcp_server=True)
|
requirements.txt
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiofiles==24.1.0
|
2 |
+
annotated-types==0.7.0
|
3 |
+
anyio==4.9.0
|
4 |
+
certifi==2025.4.26
|
5 |
+
charset-normalizer==3.4.2
|
6 |
+
click==8.1.8
|
7 |
+
fastapi==0.115.12
|
8 |
+
ffmpy==0.5.0
|
9 |
+
filelock==3.18.0
|
10 |
+
fsspec==2025.5.0
|
11 |
+
gradio==5.30.0
|
12 |
+
gradio_client==1.10.1
|
13 |
+
groovy==0.1.2
|
14 |
+
h11==0.16.0
|
15 |
+
httpcore==1.0.9
|
16 |
+
httpx==0.28.1
|
17 |
+
httpx-sse==0.4.0
|
18 |
+
huggingface-hub==0.31.4
|
19 |
+
idna==3.10
|
20 |
+
Jinja2==3.1.6
|
21 |
+
joblib==1.5.0
|
22 |
+
markdown-it-py==3.0.0
|
23 |
+
MarkupSafe==3.0.2
|
24 |
+
mcp==1.9.0
|
25 |
+
mdurl==0.1.2
|
26 |
+
nltk==3.9.1
|
27 |
+
numpy==2.2.6
|
28 |
+
orjson==3.10.18
|
29 |
+
packaging==25.0
|
30 |
+
pandas==2.2.3
|
31 |
+
pillow==11.2.1
|
32 |
+
pydantic==2.11.4
|
33 |
+
pydantic-settings==2.9.1
|
34 |
+
pydantic_core==2.33.2
|
35 |
+
pydub==0.25.1
|
36 |
+
Pygments==2.19.1
|
37 |
+
python-dateutil==2.9.0.post0
|
38 |
+
python-dotenv==1.1.0
|
39 |
+
python-multipart==0.0.20
|
40 |
+
pytz==2025.2
|
41 |
+
PyYAML==6.0.2
|
42 |
+
regex==2024.11.6
|
43 |
+
requests==2.32.3
|
44 |
+
rich==14.0.0
|
45 |
+
ruff==0.11.10
|
46 |
+
safehttpx==0.1.6
|
47 |
+
semantic-version==2.10.0
|
48 |
+
shellingham==1.5.4
|
49 |
+
six==1.17.0
|
50 |
+
sniffio==1.3.1
|
51 |
+
sse-starlette==2.3.5
|
52 |
+
starlette==0.46.2
|
53 |
+
textblob==0.19.0
|
54 |
+
tomlkit==0.13.2
|
55 |
+
tqdm==4.67.1
|
56 |
+
typer==0.15.4
|
57 |
+
typing-inspection==0.4.0
|
58 |
+
typing_extensions==4.13.2
|
59 |
+
tzdata==2025.2
|
60 |
+
urllib3==2.4.0
|
61 |
+
uvicorn==0.34.2
|
62 |
+
websockets==15.0.1
|