Spaces:
Sleeping
Sleeping
André Oriani commited on
Commit ·
a5b902b
1
Parent(s): 9a2520c
Initial commit
Browse files- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/mcp-sentiment.iml +10 -0
- .idea/modules.xml +8 -0
- .idea/vcs.xml +6 -0
- .idea/workspace.xml +94 -0
- app.py +36 -0
- requirements.txt +2 -0
.idea/inspectionProfiles/profiles_settings.xml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<component name="InspectionProjectProfileManager">
|
| 2 |
+
<settings>
|
| 3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
| 4 |
+
<version value="1.0" />
|
| 5 |
+
</settings>
|
| 6 |
+
</component>
|
.idea/mcp-sentiment.iml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<module type="PYTHON_MODULE" version="4">
|
| 3 |
+
<component name="NewModuleRootManager">
|
| 4 |
+
<content url="file://$MODULE_DIR$">
|
| 5 |
+
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
| 6 |
+
</content>
|
| 7 |
+
<orderEntry type="jdk" jdkName="Python 3.12 (mcp-sentiment)" jdkType="Python SDK" />
|
| 8 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
| 9 |
+
</component>
|
| 10 |
+
</module>
|
.idea/modules.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="ProjectModuleManager">
|
| 4 |
+
<modules>
|
| 5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/mcp-sentiment.iml" filepath="$PROJECT_DIR$/.idea/mcp-sentiment.iml" />
|
| 6 |
+
</modules>
|
| 7 |
+
</component>
|
| 8 |
+
</project>
|
.idea/vcs.xml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="VcsDirectoryMappings">
|
| 4 |
+
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
| 5 |
+
</component>
|
| 6 |
+
</project>
|
.idea/workspace.xml
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="AutoImportSettings">
|
| 4 |
+
<option name="autoReloadType" value="SELECTIVE" />
|
| 5 |
+
</component>
|
| 6 |
+
<component name="ChangeListManager">
|
| 7 |
+
<list default="true" id="b116071f-6865-41db-ae42-07e2aa1d2040" name="Changes" comment="">
|
| 8 |
+
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" afterDir="false" />
|
| 9 |
+
<change afterPath="$PROJECT_DIR$/.idea/mcp-sentiment.iml" afterDir="false" />
|
| 10 |
+
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
| 11 |
+
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
| 12 |
+
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
| 13 |
+
<change afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
|
| 14 |
+
<change afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
|
| 15 |
+
</list>
|
| 16 |
+
<option name="SHOW_DIALOG" value="false" />
|
| 17 |
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
| 18 |
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
| 19 |
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
| 20 |
+
</component>
|
| 21 |
+
<component name="FileTemplateManagerImpl">
|
| 22 |
+
<option name="RECENT_TEMPLATES">
|
| 23 |
+
<list>
|
| 24 |
+
<option value="Python Script" />
|
| 25 |
+
</list>
|
| 26 |
+
</option>
|
| 27 |
+
</component>
|
| 28 |
+
<component name="Git.Settings">
|
| 29 |
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
| 30 |
+
</component>
|
| 31 |
+
<component name="ProjectColorInfo"><![CDATA[{
|
| 32 |
+
"associatedIndex": 6
|
| 33 |
+
}]]></component>
|
| 34 |
+
<component name="ProjectId" id="2xb9nG0NiTnTqJIs3oE94sT60oI" />
|
| 35 |
+
<component name="ProjectViewState">
|
| 36 |
+
<option name="hideEmptyMiddlePackages" value="true" />
|
| 37 |
+
<option name="showLibraryContents" value="true" />
|
| 38 |
+
</component>
|
| 39 |
+
<component name="PropertiesComponent"><![CDATA[{
|
| 40 |
+
"keyToString": {
|
| 41 |
+
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
| 42 |
+
"Python.app.executor": "Run",
|
| 43 |
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
| 44 |
+
"RunOnceActivity.git.unshallow": "true",
|
| 45 |
+
"git-widget-placeholder": "main"
|
| 46 |
+
}
|
| 47 |
+
}]]></component>
|
| 48 |
+
<component name="RunManager">
|
| 49 |
+
<configuration name="app" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
| 50 |
+
<module name="mcp-sentiment" />
|
| 51 |
+
<option name="ENV_FILES" value="" />
|
| 52 |
+
<option name="INTERPRETER_OPTIONS" value="" />
|
| 53 |
+
<option name="PARENT_ENVS" value="true" />
|
| 54 |
+
<envs>
|
| 55 |
+
<env name="PYTHONUNBUFFERED" value="1" />
|
| 56 |
+
</envs>
|
| 57 |
+
<option name="SDK_HOME" value="" />
|
| 58 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
| 59 |
+
<option name="IS_MODULE_SDK" value="true" />
|
| 60 |
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
| 61 |
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
| 62 |
+
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/app.py" />
|
| 63 |
+
<option name="PARAMETERS" value="" />
|
| 64 |
+
<option name="SHOW_COMMAND_LINE" value="false" />
|
| 65 |
+
<option name="EMULATE_TERMINAL" value="false" />
|
| 66 |
+
<option name="MODULE_MODE" value="false" />
|
| 67 |
+
<option name="REDIRECT_INPUT" value="false" />
|
| 68 |
+
<option name="INPUT_FILE" value="" />
|
| 69 |
+
<method v="2" />
|
| 70 |
+
</configuration>
|
| 71 |
+
<recent_temporary>
|
| 72 |
+
<list>
|
| 73 |
+
<item itemvalue="Python.app" />
|
| 74 |
+
</list>
|
| 75 |
+
</recent_temporary>
|
| 76 |
+
</component>
|
| 77 |
+
<component name="SharedIndexes">
|
| 78 |
+
<attachedChunks>
|
| 79 |
+
<set>
|
| 80 |
+
<option value="bundled-python-sdk-dfff61a61320-9cdd278e9d02-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-251.25410.159" />
|
| 81 |
+
</set>
|
| 82 |
+
</attachedChunks>
|
| 83 |
+
</component>
|
| 84 |
+
<component name="TaskManager">
|
| 85 |
+
<task active="true" id="Default" summary="Default task">
|
| 86 |
+
<changelist id="b116071f-6865-41db-ae42-07e2aa1d2040" name="Changes" comment="" />
|
| 87 |
+
<created>1748196070353</created>
|
| 88 |
+
<option name="number" value="Default" />
|
| 89 |
+
<option name="presentableId" value="Default" />
|
| 90 |
+
<updated>1748196070353</updated>
|
| 91 |
+
</task>
|
| 92 |
+
<servers />
|
| 93 |
+
</component>
|
| 94 |
+
</project>
|
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from textblob import TextBlob
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def sentiment_analysis(text: str) -> dict:
|
| 6 |
+
"""
|
| 7 |
+
Analyze the sentiment of the given text.
|
| 8 |
+
|
| 9 |
+
Args:
|
| 10 |
+
text (str): The text to analyze
|
| 11 |
+
|
| 12 |
+
Returns:
|
| 13 |
+
dict: A dictionary containing polarity, subjectivity, and assessment
|
| 14 |
+
"""
|
| 15 |
+
blob = TextBlob(text)
|
| 16 |
+
sentiment = blob.sentiment
|
| 17 |
+
|
| 18 |
+
return {
|
| 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 |
+
|
| 25 |
+
# Create the Gradio interface
|
| 26 |
+
demo = gr.Interface(
|
| 27 |
+
fn=sentiment_analysis,
|
| 28 |
+
inputs=gr.Textbox(placeholder="Enter text to analyze..."),
|
| 29 |
+
outputs=gr.JSON(),
|
| 30 |
+
title="Text Sentiment Analysis",
|
| 31 |
+
description="Analyze the sentiment of text using TextBlob"
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
# Launch the interface and MCP server
|
| 35 |
+
if __name__ == "__main__":
|
| 36 |
+
demo.launch(mcp_server=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio[mcp]
|
| 2 |
+
textblob
|