File size: 492 Bytes
750f86e
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import gradio as gr
from textblob import TextBlob

# Define the sentiment analysis function
def analyze_sentiment(text):
	blob = TextBlob(text)
	polarity = blob.sentiment.polarity
	subjectivity = blob.sentiment.subjectivity
	sentiment = "POSITIVE" if polarity >= 0 else "NEGATIVE"
	return f"Sentiment: {sentiment}\nPolarity: {polarity:.2f}\nSubjectivity: {subjectivity:.2%}"

# Create a Gradio interface
iface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text")
iface.launch()