| import gradio as gr |
| from textblob import TextBlob |
|
|
| def analyze_sentiment(text: str) -> str: |
| """ |
| Analyze the sentiment of the provided text. |
| |
| Args: |
| text (str): The text to analyze. |
| |
| Returns: |
| str: The sentiment polarity and subjectivity. |
| """ |
| blob = TextBlob(text) |
| polarity = blob.sentiment.polarity |
| subjectivity = blob.sentiment.subjectivity |
| return f"Polarity: {polarity}, Subjectivity: {subjectivity}" |
|
|
| demo = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text", title="Sentiment Analyzer", enable_mcp=True) |
| demo.launch() |
|
|