ashok2216 commited on
Commit
94c0eb7
·
verified ·
1 Parent(s): aa1f18e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -11
app.py CHANGED
@@ -1,20 +1,30 @@
1
  import streamlit as st
2
  import seaborn as sns
3
- # import data_cleaning
4
  from transformers import pipeline
5
 
6
 
7
  sentiment_model = pipeline(model="ashok2216/gpt2-amazon-sentiment-classifier")
8
 
9
- st.markdown(sentiment_model(['It is Super!']))
 
 
 
10
 
11
- # sentiments = []
12
- # for text in df['clean_text']:
13
- # if list(sentiment_model(text)[0].values())[0] == 'LABEL_1':
14
- # output = 'Positive'
15
- # else:
16
- # output = 'Negative'
17
- # sentiments.append(output)
18
 
19
- # df['sentiments'] = sentiments
20
- # sns.countplot(df['sentiments'])
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import seaborn as sns
3
+ from data_cleaning import preprocess
4
  from transformers import pipeline
5
 
6
 
7
  sentiment_model = pipeline(model="ashok2216/gpt2-amazon-sentiment-classifier")
8
 
9
+ # Example usage:
10
+ sample_url = 'https://www.amazon.in/OnePlus-Nord-Pastel-128GB-Storage/product-reviews/B0BY8JZ22K/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviews'
11
+ url = st.text_input("Amazon product link", sample_url)
12
+ st.write("The current movie title is", url)
13
 
14
+ all_reviews = scrape_all_pages(url)
15
+ # Convert to DataFrame for further analysis
16
+ reviews = pd.DataFrame(all_reviews)
17
+ processed_text = reviews[content]
 
 
 
18
 
19
+ # st.markdown(sentiment_model(['It is Super!']))
20
+
21
+ sentiments = []
22
+ for text in processed_text:
23
+ if list(sentiment_model(text)[0].values())[0] == 'LABEL_1':
24
+ output = 'Positive'
25
+ else:
26
+ output = 'Negative'
27
+ sentiments.append(output)
28
+
29
+ df['sentiments'] = sentiments
30
+ sns.countplot(df['sentiments'])