wgcv commited on
Commit
5778c00
·
1 Parent(s): 4d42aec
Files changed (2) hide show
  1. app.py +37 -0
  2. requirements.txt +70 -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,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==24.1.0
2
+ annotated-types==0.7.0
3
+ anyio==4.9.0
4
+ attrs==25.3.0
5
+ audioop-lts==0.2.1
6
+ Brotli==1.1.0
7
+ certifi==2025.7.14
8
+ charset-normalizer==3.4.2
9
+ click==8.2.1
10
+ fastapi==0.116.1
11
+ ffmpy==0.6.1
12
+ filelock==3.18.0
13
+ fsspec==2025.7.0
14
+ gradio==5.38.0
15
+ gradio_client==1.11.0
16
+ groovy==0.1.2
17
+ h11==0.16.0
18
+ hf-xet==1.1.5
19
+ httpcore==1.0.9
20
+ httpx==0.28.1
21
+ httpx-sse==0.4.1
22
+ huggingface-hub==0.33.4
23
+ idna==3.10
24
+ Jinja2==3.1.6
25
+ joblib==1.5.1
26
+ jsonschema==4.25.0
27
+ jsonschema-specifications==2025.4.1
28
+ markdown-it-py==3.0.0
29
+ MarkupSafe==3.0.2
30
+ mcp==1.10.1
31
+ mdurl==0.1.2
32
+ nltk==3.9.1
33
+ numpy==2.3.1
34
+ orjson==3.11.0
35
+ packaging==25.0
36
+ pandas==2.3.1
37
+ pillow==11.3.0
38
+ pydantic==2.11.7
39
+ pydantic-settings==2.10.1
40
+ pydantic_core==2.33.2
41
+ pydub==0.25.1
42
+ Pygments==2.19.2
43
+ python-dateutil==2.9.0.post0
44
+ python-dotenv==1.1.1
45
+ python-multipart==0.0.20
46
+ pytz==2025.2
47
+ PyYAML==6.0.2
48
+ referencing==0.36.2
49
+ regex==2024.11.6
50
+ requests==2.32.4
51
+ rich==14.0.0
52
+ rpds-py==0.26.0
53
+ ruff==0.12.4
54
+ safehttpx==0.1.6
55
+ semantic-version==2.10.0
56
+ shellingham==1.5.4
57
+ six==1.17.0
58
+ sniffio==1.3.1
59
+ sse-starlette==2.4.1
60
+ starlette==0.47.2
61
+ textblob==0.19.0
62
+ tomlkit==0.13.3
63
+ tqdm==4.67.1
64
+ typer==0.16.0
65
+ typing-inspection==0.4.1
66
+ typing_extensions==4.14.1
67
+ tzdata==2025.2
68
+ urllib3==2.5.0
69
+ uvicorn==0.35.0
70
+ websockets==15.0.1