sm2899 commited on
Commit
e222a8f
1 Parent(s): a9a1b09

Create sentiment-analyser.py

Browse files
Files changed (1) hide show
  1. sentiment-analyser.py +24 -0
sentiment-analyser.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ st.title('Sentiment Analyser App')
5
+ st.write('Welcome to my sentiment analysis app!')
6
+
7
+ form = st.form(key='sentiment-form')
8
+ user_input = form.text_area('Enter your text')
9
+ submit = form.form_submit_button('Submit')
10
+
11
+ classifier = pipeline("sentiment-analysis")
12
+ result = classifier(user_input)[0]
13
+ label = result['label']
14
+ score = result['score']
15
+
16
+ if submit:
17
+ classifier = pipeline("sentiment-analysis")
18
+ result = classifier(user_input)[0]
19
+ label = result['label']
20
+ score = result['score']
21
+ if label == 'POSITIVE':
22
+ st.success(f'{label} sentiment (score: {score})')
23
+ else:
24
+ st.error(f'{label} sentiment (score: {score})')