Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,34 @@
|
|
| 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("
|
| 9 |
-
option = st.selectbox('Choose Framework:',('Transformers', 'TextBlob'))
|
| 10 |
|
| 11 |
st.subheader("Enter the text you want to analyze")
|
| 12 |
-
text = st.text_input('Enter text:')
|
| 13 |
-
|
| 14 |
-
if
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
st.write("Sentiment of Text:
|
| 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("Choose Framework:")
|
| 16 |
+
option = st.selectbox('Choose Framework:', ('Transformers', 'TextBlob'))
|
| 17 |
|
| 18 |
st.subheader("Enter the text you want to analyze")
|
| 19 |
+
text = st.text_input('Enter text:')
|
| 20 |
+
|
| 21 |
+
if text:
|
| 22 |
+
if option == 'Transformers':
|
| 23 |
+
out = pipe(text)
|
| 24 |
+
else:
|
| 25 |
+
out = TextBlob(text).sentiment
|
| 26 |
+
|
| 27 |
+
st.write("Sentiment of Text:", out)
|
| 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())
|