Spaces:
Running
Running
File size: 828 Bytes
aecf7b3 dd123fe 9ef7f06 dd123fe 9ef7f06 aecf7b3 912acd5 aecf7b3 dd123fe aecf7b3 | 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 | import streamlit as st
from transformers import pipeline
from textblob import TextBlob
pipe = pipeline('sentiment-analysis')
st.title("Sentiment Analysis")
st.subheader("Which framework would you like to use for sentiment analysis?")
option = st.selectbox('Choose Framework:',('Transformers', 'TextBlob')) # option is stored in this variable
st.subheader("Enter the text you want to analyze")
text = st.text_input('Enter text:') # text is stored in this variable
if option == 'Transformers':
result = pipe(text)[0]
label = result['label']
score = round(result['score'] * 100, 2)
if label == "POSITIVE":
emoji = "๐"
else:
emoji = "๐"
out = f"{emoji} {label} ({score}%)"
else:
out = TextBlob(text)
out = out.sentiment
st.write("Sentiment of Text: ")
st.write(out)
|