layers2024 commited on
Commit
9116cf3
·
verified ·
1 Parent(s): d798ce7

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. .gitignore +136 -0
  2. README.md +2 -8
  3. app.py +41 -0
  4. requirements.txt +2 -0
.gitignore ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+ MANIFEST
27
+
28
+ # PyInstaller files
29
+ *.manifest
30
+ *.spec
31
+
32
+ # Installer logs
33
+ pip-log.txt
34
+ pip-delete-this-directory.txt
35
+
36
+ # Unit test / coverage reports
37
+ htmlcov/
38
+ .tox/
39
+ .nox/
40
+ .coverage
41
+ .coverage.*
42
+ .cache
43
+ nosetests.xml
44
+ coverage.xml
45
+ *.cover
46
+ .hypothesis/
47
+ .pytest_cache/
48
+
49
+ # Translations
50
+ *.mo
51
+ *.pot
52
+
53
+ # Django specific
54
+ *.log
55
+ local_settings.py
56
+ db.sqlite3
57
+ db.sqlite3-journal
58
+
59
+ # Flask specific
60
+ instance/
61
+ .webassets-cache
62
+
63
+ # Scrapy
64
+ .scrapy
65
+
66
+ # Documentation builds
67
+ docs/_build/
68
+
69
+ # PyBuilder
70
+ .pybuilder/
71
+ target/
72
+
73
+ # Jupyter Notebooks
74
+ .ipynb_checkpoints
75
+
76
+ # IPython
77
+ profile_default/
78
+ ipython_config.py
79
+
80
+ # pyenv
81
+ .python-version
82
+
83
+ # Environment directories
84
+ .env
85
+ .envrc
86
+ .venv
87
+ env/
88
+ venv/
89
+ ENV/
90
+ env.bak/
91
+ venv.bak/
92
+
93
+ # PEP 582
94
+ __pypackages__/
95
+
96
+ # Celery
97
+ celerybeat-schedule
98
+ celerybeat.pid
99
+
100
+ # SageMath
101
+ *.sage.py
102
+
103
+ # IDE / Editor directories
104
+ .idea/
105
+ .vscode/
106
+ *.sublime-project
107
+ *.sublime-workspace
108
+
109
+ # Spyder
110
+ .spyderproject
111
+ .spyproject
112
+
113
+ # Rope
114
+ .ropeproject
115
+
116
+ # mkdocs
117
+ /site
118
+
119
+ # mypy
120
+ .mypy_cache/
121
+ .dmypy.json
122
+ dmypy.json
123
+
124
+ # Pyre
125
+ .pyre/
126
+
127
+ # pytype
128
+ .pytype/
129
+
130
+ # Cython debug symbols
131
+ cython_debug/
132
+
133
+ # Logs and misc
134
+ *.log
135
+ *.sqlite
136
+ *.db
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: Mcp Sentiment
3
- emoji:
4
- colorFrom: pink
5
- colorTo: blue
6
  sdk: gradio
7
  sdk_version: 5.43.1
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: mcp-sentiment
3
+ app_file: app.py
 
 
4
  sdk: gradio
5
  sdk_version: 5.43.1
 
 
6
  ---
 
 
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import gradio as gr
3
+ from textblob import TextBlob
4
+
5
+
6
+ def sentiment_analysis(text: str) -> str:
7
+ """
8
+ Analyze the sentiment of the given text.
9
+
10
+ Args:
11
+ text (str): The text to analyze
12
+
13
+ Returns:
14
+ str: A JSON string containing polarity, subjectivity, and assessment
15
+ """
16
+ blob = TextBlob(text)
17
+ sentiment = blob.sentiment
18
+
19
+ result = {
20
+ # -1 (negative) to 1 (positive)
21
+ "polarity": round(sentiment.polarity, 2),
22
+ # 0 (objective) to 1 (subjective)
23
+ "subjectivity": round(sentiment.subjectivity, 2),
24
+ "assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
25
+ }
26
+
27
+ return json.dumps(result)
28
+
29
+
30
+ # Create the Gradio interface
31
+ demo = gr.Interface(
32
+ fn=sentiment_analysis,
33
+ inputs=gr.Textbox(placeholder="Enter text to analyze..."),
34
+ outputs=gr.Textbox(), # Changed from gr.JSON() to gr.Textbox()
35
+ title="Text Sentiment Analysis",
36
+ description="Analyze the sentiment of text using TextBlob"
37
+ )
38
+
39
+ # Launch the interface and MCP server
40
+ if __name__ == "__main__":
41
+ demo.launch(mcp_server=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio[mcp]
2
+ textblob