Update app.py

#1
by shdira - opened
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -12,7 +12,17 @@ st.subheader("Enter the text you want to analyze")
12
  text = st.text_input('Enter text:') # text is stored in this variable
13
 
14
  if option == 'Transformers':
15
- out = pipe(text)
 
 
 
 
 
 
 
 
 
 
16
  else:
17
  out = TextBlob(text)
18
  out = out.sentiment
 
12
  text = st.text_input('Enter text:') # text is stored in this variable
13
 
14
  if option == 'Transformers':
15
+ result = pipe(text)[0]
16
+
17
+ label = result['label']
18
+ score = round(result['score'] * 100, 2)
19
+
20
+ if label == "POSITIVE":
21
+ emoji = "😊"
22
+ else:
23
+ emoji = "😞"
24
+
25
+ out = f"{emoji} {label} ({score}%)"
26
  else:
27
  out = TextBlob(text)
28
  out = out.sentiment