Spaces:
Running
Running
Download app.py from Reply2susi/MCP_E2E_App: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/Reply2susi/MCP_E2E_App/resolve/main/app.py
- Command line
-
hf download hf://spaces/Reply2susi/MCP_E2E_App/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Reply2susi/MCP_E2E_App/resolve/main/app.py
1.07 kB
| import gradio as gr | |
| from textblob import TextBlob | |
| def analyze_sentiment(text): | |
| try: | |
| if not text or not text.strip(): | |
| return "Please enter some text to analyze" | |
| blob = TextBlob(text) | |
| polarity = blob.sentiment.polarity | |
| if polarity > 0.1: | |
| return f"✅ Positive sentiment (score: {polarity:.2f})" | |
| elif polarity < -0.1: | |
| return f"❌ Negative sentiment (score: {polarity:.2f})" | |
| else: | |
| return f"😐 Neutral sentiment (score: {polarity:.2f})" | |
| except Exception as e: | |
| return f"Error: {str(e)}" | |
| demo = gr.Interface( | |
| fn=analyze_sentiment, | |
| inputs=gr.Textbox(label="text", placeholder="Enter text to analyze..."), | |
| outputs=gr.Textbox(label="output"), | |
| title="Text Sentiment Analysis", | |
| description="Analyze the sentiment of text using TextBlob" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch( | |
| server_name="0.0.0.0", | |
| server_port=7860, | |
| share=False, | |
| debug=False, | |
| show_error=True | |
| ) |