File size: 898 Bytes
2812448
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
import gradio as gr

# Simple dummy function for sentiment
def predict_sentiment(text):
    positive_words = ['good', 'happy', 'awesome', 'best', 'fantastic', 'love']
    negative_words = ['bad', 'sad', 'terrible', 'worst', 'hate', 'awful']

    text = text.lower()
    score = 0

    for word in positive_words:
        if word in text:
            score += 1
    for word in negative_words:
        if word in text:
            score -= 1

    if score > 0:
        return "Positive πŸ˜€"
    elif score < 0:
        return "Negative 😞"
    else:
        return "Neutral 😐"

# Build Gradio Interface
interface = gr.Interface(
    fn=predict_sentiment,
    inputs="text",
    outputs="text",
    title="Simple Sentiment Analyzer",
    description="Enter a sentence and get the sentiment prediction!",
    theme="default"
)

# Launch the app
if __name__ == "__main__":
    interface.launch()