Spaces:
Runtime error
Runtime error
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: MCP Sentiment Analysis
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 5.0.0
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# π Text Sentiment Analysis with MCP
|
| 13 |
+
|
| 14 |
+
A powerful sentiment analysis tool built with Gradio and TextBlob, featuring Model Context Protocol (MCP) server integration for AI assistant interoperability.
|
| 15 |
+
|
| 16 |
+
## π Features
|
| 17 |
+
|
| 18 |
+
- **Real-time Sentiment Analysis**: Analyze the emotional tone of any text instantly
|
| 19 |
+
- **Polarity Score**: Measures sentiment from -1 (negative) to +1 (positive)
|
| 20 |
+
- **Subjectivity Score**: Evaluates objectivity (0) vs subjectivity (1)
|
| 21 |
+
- **MCP Server Integration**: Expose sentiment analysis as a tool for AI assistants
|
| 22 |
+
- **Clean Web Interface**: User-friendly Gradio interface
|
| 23 |
+
|
| 24 |
+
## π How It Works
|
| 25 |
+
|
| 26 |
+
The application uses **TextBlob**, a Python library for natural language processing that:
|
| 27 |
+
1. Tokenizes and analyzes input text
|
| 28 |
+
2. Applies sentiment lexicon algorithms
|
| 29 |
+
3. Returns polarity, subjectivity, and overall assessment
|
| 30 |
+
|
| 31 |
+
### Output Metrics
|
| 32 |
+
|
| 33 |
+
- **Polarity**: Emotional tone ranging from -1.0 (very negative) to +1.0 (very positive)
|
| 34 |
+
- **Subjectivity**: Opinion level from 0.0 (objective/factual) to 1.0 (subjective/opinionated)
|
| 35 |
+
- **Assessment**: Simple classification (positive, negative, or neutral)
|
| 36 |
+
|
| 37 |
+
## π‘ Example Usage
|
| 38 |
+
|
| 39 |
+
**Input:**
|
| 40 |
+
```
|
| 41 |
+
I absolutely love this product! It's amazing!
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
**Output:**
|
| 45 |
+
```json
|
| 46 |
+
{
|
| 47 |
+
"polarity": 0.75,
|
| 48 |
+
"subjectivity": 0.95,
|
| 49 |
+
"assessment": "positive"
|
| 50 |
+
}
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## π§ Technologies Used
|
| 54 |
+
|
| 55 |
+
- **Gradio**: Web UI framework with MCP support
|
| 56 |
+
- **TextBlob**: NLP library for sentiment analysis
|
| 57 |
+
- **Python 3.13**: Core programming language
|
| 58 |
+
|
| 59 |
+
## π€ MCP Integration
|
| 60 |
+
|
| 61 |
+
This Space runs as an MCP server, allowing AI assistants (like Claude) to discover and use the `sentiment_analysis` function as a tool. This enables AI assistants to analyze sentiment in real-time during conversations.
|
| 62 |
+
|
| 63 |
+
## π οΈ Local Development
|
| 64 |
+
|
| 65 |
+
```bash
|
| 66 |
+
# Clone the repository
|
| 67 |
+
git clone https://huggingface.co/spaces/SpringDai/mcp-sentiment
|
| 68 |
+
|
| 69 |
+
# Install dependencies
|
| 70 |
+
pip install -r requirements.txt
|
| 71 |
+
|
| 72 |
+
# Run the application
|
| 73 |
+
python app.py
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
## π License
|
| 77 |
+
|
| 78 |
+
Open source - feel free to use and modify!
|
| 79 |
+
|
| 80 |
+
## π€ Author
|
| 81 |
+
|
| 82 |
+
Created by [SpringDai](https://huggingface.co/SpringDai)
|