File size: 662 Bytes
76c6334
4066f8e
76c6334
4066f8e
 
 
 
 
 
 
 
 
 
76c6334
4066f8e
4f309da
 
 
de1b425
4066f8e
 
2e37ab6
4066f8e
 
de1b425
4066f8e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import gradio as gr
from textblob import TextBlob

def analyze_sentiment(text):
    blob = TextBlob(text)
    sentiment = blob.sentiment.polarity
    if sentiment > 0:
        color = "green"
    elif sentiment < 0:
        color = "red"
    else:
        color = "yellow"
    return color, label

def sentiment_analysis(text):
    color = analyze_sentiment(text)
    # return "<h2 style='color:{}; text-align:center;'>{} Sentiment</h2>".format(color, label)
    return "<i class="fa-brands fa-font-awesome" style="color: {};"></i>".format(color, label)

iface = gr.Interface(
    fn=sentiment_analysis, 
    inputs="text", 
    outputs="html"
)

iface.launch()