Mushfiqur-Rahman-Robin commited on
Commit
3fa49f2
·
0 Parent(s):

added initial commit

Browse files
Files changed (6) hide show
  1. .gitignore +11 -0
  2. .python-version +1 -0
  3. README.md +0 -0
  4. app.py +34 -0
  5. pyproject.toml +7 -0
  6. requirements.txt +66 -0
.gitignore ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
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
+ .ruff_cache
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.9
README.md ADDED
File without changes
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)
pyproject.toml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "sentiment-analysis-mcp"
3
+ version = "0.1.0"
4
+ description = "As part of the MCP course at HuggingFace, a simple sentiment analysis project is created."
5
+ readme = "README.md"
6
+ requires-python = ">=3.9"
7
+ dependencies = []
requirements.txt ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==24.1.0
2
+ annotated-types==0.7.0
3
+ anyio==4.9.0
4
+ audioop-lts==0.2.1
5
+ certifi==2025.4.26
6
+ charset-normalizer==3.4.2
7
+ click==8.1.8
8
+ fastapi==0.115.12
9
+ ffmpy==0.5.0
10
+ filelock==3.18.0
11
+ fsspec==2025.5.0
12
+ gradio==5.30.0
13
+ gradio-client==1.10.1
14
+ groovy==0.1.2
15
+ h11==0.16.0
16
+ httpcore==1.0.9
17
+ httpx==0.28.1
18
+ httpx-sse==0.4.0
19
+ huggingface-hub==0.31.4
20
+ idna==3.10
21
+ jinja2==3.1.6
22
+ joblib==1.5.0
23
+ markdown-it-py==3.0.0
24
+ markupsafe==3.0.2
25
+ mcp==1.9.0
26
+ mdurl==0.1.2
27
+ nltk==3.9.1
28
+ numpy==2.2.6
29
+ orjson==3.10.18
30
+ packaging==25.0
31
+ pandas==2.2.3
32
+ pillow==11.2.1
33
+ pip @ file:///croot/pip_1746204010231/work
34
+ pydantic==2.11.4
35
+ pydantic-core==2.33.2
36
+ pydantic-settings==2.9.1
37
+ pydub==0.25.1
38
+ pygments==2.19.1
39
+ python-dateutil==2.9.0.post0
40
+ python-dotenv==1.1.0
41
+ python-multipart==0.0.20
42
+ pytz==2025.2
43
+ pyyaml==6.0.2
44
+ regex==2024.11.6
45
+ requests==2.32.3
46
+ rich==14.0.0
47
+ ruff==0.11.10
48
+ safehttpx==0.1.6
49
+ semantic-version==2.10.0
50
+ setuptools==78.1.1
51
+ shellingham==1.5.4
52
+ six==1.17.0
53
+ sniffio==1.3.1
54
+ sse-starlette==2.3.5
55
+ starlette==0.46.2
56
+ textblob==0.19.0
57
+ tomlkit==0.13.2
58
+ tqdm==4.67.1
59
+ typer==0.15.4
60
+ typing-extensions==4.13.2
61
+ typing-inspection==0.4.0
62
+ tzdata==2025.2
63
+ urllib3==2.4.0
64
+ uvicorn==0.34.2
65
+ websockets==15.0.1
66
+ wheel==0.45.1