VijayPulmamidi commited on
Commit
cab374f
·
verified ·
1 Parent(s): b815bf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -8,12 +8,20 @@ def analyze_sentiment(text):
8
  result = sentiment_pipeline(text)[0]
9
  label = result['label']
10
  score = result['score']
11
- return f"{label} ({score:.2f})"
 
 
 
 
12
 
13
- interface = gr.Interface(fn=analyze_sentiment,
14
- inputs="text",
15
- outputs="text",
16
- title="Sentiment Analyzer",
17
- description="Type a sentence to see if it's Positive or Negative")
 
 
 
18
 
 
19
  interface.launch()
 
8
  result = sentiment_pipeline(text)[0]
9
  label = result['label']
10
  score = result['score']
11
+
12
+ # Set emoji based on sentiment
13
+ emoji = "🙂" if label == "POSITIVE" else "☹️"
14
+
15
+ return f"{emoji} {label} ({score:.2f})", score
16
 
17
+ # Create Gradio interface
18
+ interface = gr.Interface(
19
+ fn=analyze_sentiment,
20
+ inputs="text",
21
+ outputs=[gr.Textbox(), gr.Slider(minimum=0, maximum=1, step=0.01)], # New: Confidence bar
22
+ title="Sentiment Analyzer",
23
+ description="Type a sentence to see if it's Positive or Negative",
24
+ )
25
 
26
+ # Launch the app
27
  interface.launch()