Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
from textblob import TextBlob
|
| 4 |
+
model_name= "finiteautomata/bertweet-base-sentiment-analysis"
|
| 5 |
+
pipe = pipeline(model_name)
|
| 6 |
+
st.title("Sentiment Analysis")
|
| 7 |
+
|
| 8 |
+
st.subheader("Which framework would you like to use for sentiment analysis?")
|
| 9 |
+
option = st.selectbox('Choose Framework:',('Transformers', 'TextBlob')) # option is stored in this variable
|
| 10 |
+
|
| 11 |
+
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
|
| 19 |
+
|
| 20 |
+
st.write("Sentiment of Text: ")
|
| 21 |
+
st.write(out)
|