Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,21 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import pandas as pd
|
| 3 |
from transformers import pipeline
|
| 4 |
from textblob import TextBlob
|
| 5 |
-
from datasets import load_dataset
|
| 6 |
-
|
| 7 |
-
# Load dataset
|
| 8 |
-
|
| 9 |
-
df = load_dataset("gxb912/large-twitter-tweets-sentiment")
|
| 10 |
-
|
| 11 |
-
pipe = pipeline(f"cardiffnlp/twitter-roberta-base-{task}")
|
| 12 |
|
|
|
|
| 13 |
st.title("Sentiment Analysis")
|
| 14 |
|
| 15 |
-
st.subheader("
|
| 16 |
-
option = st.selectbox('Choose Framework:',
|
| 17 |
|
| 18 |
st.subheader("Enter the text you want to analyze")
|
| 19 |
-
text = st.text_input('Enter text:')
|
| 20 |
-
|
| 21 |
-
if
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
# Display dataset insights
|
| 30 |
-
if st.checkbox("Show dataset sample"):
|
| 31 |
-
st.write(df.head())
|
| 32 |
-
|
| 33 |
-
if st.checkbox("Show dataset statistics"):
|
| 34 |
-
st.write(df.describe())
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
from textblob import TextBlob
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
pipe = pipeline('sentiment-analysis')
|
| 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|