TheAang commited on
Commit
34ddcad
·
verified ·
1 Parent(s): 41368fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -13
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("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)
 
 
 
 
 
 
 
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())