ashok2216 commited on
Commit
f37ced0
·
verified ·
1 Parent(s): 1fba1d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -21
app.py CHANGED
@@ -43,7 +43,7 @@ right: 2rem;
43
  st.markdown(page_bg_img, unsafe_allow_html=True)
44
  # st.image("logo.png", width=200, height=200)
45
  st.image("logo.png", width=100)
46
- st.subheader(':darkblue[NLP HUB®]')
47
  st.markdown("")
48
  st.markdown("")
49
  st.markdown("")
@@ -58,26 +58,30 @@ sentiment_model = pipeline(model="ashok2216/gpt2-amazon-sentiment-classifier")
58
  # Example usage:-
59
  sample_url = 'https://www.amazon.in/Dell-Inspiron-i7-1255U-Processor-Platinum/product-reviews/B0C9F142V6/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviews'
60
  url = st.text_input("Amazon product link", sample_url)
61
- st.button("Say hello")
62
  st.write("Done")
63
  st.subheader('', divider='rainbow')
64
- all_reviews = scrape_all_pages(url)
65
- # Convert to DataFrame for further analysis
66
- reviews = pd.DataFrame(all_reviews)
67
- reviews['processed_text'] = reviews['content'].apply(preprocess)
68
 
69
- # st.dataframe(reviews, use_container_width=True)
70
- # st.markdown(sentiment_model(['It is Super!']))
71
-
72
- sentiments = []
73
- for text in reviews['processed_text']:
74
- if list(sentiment_model(text)[0].values())[0] == 'LABEL_1':
75
- output = 'Positive'
76
- else:
77
- output = 'Negative'
78
- sentiments.append(output)
79
-
80
- reviews['sentiments'] = sentiments
81
- st.markdown(':white[Output]')
82
- st.dataframe(reviews, use_container_width=True)
83
- # sns.countplot(reviews['sentiments'])
 
 
 
 
 
 
 
 
 
43
  st.markdown(page_bg_img, unsafe_allow_html=True)
44
  # st.image("logo.png", width=200, height=200)
45
  st.image("logo.png", width=100)
46
+ st.subheader(':violet[NLP HUB®]')
47
  st.markdown("")
48
  st.markdown("")
49
  st.markdown("")
 
58
  # Example usage:-
59
  sample_url = 'https://www.amazon.in/Dell-Inspiron-i7-1255U-Processor-Platinum/product-reviews/B0C9F142V6/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviews'
60
  url = st.text_input("Amazon product link", sample_url)
61
+ st.button("Re-run")
62
  st.write("Done")
63
  st.subheader('', divider='rainbow')
 
 
 
 
64
 
65
+ try:
66
+ all_reviews = scrape_all_pages(url)
67
+ # Convert to DataFrame for further analysis
68
+ reviews = pd.DataFrame(all_reviews)
69
+ reviews['processed_text'] = reviews['content'].apply(preprocess)
70
+
71
+ # st.dataframe(reviews, use_container_width=True)
72
+ # st.markdown(sentiment_model(['It is Super!']))
73
+
74
+ sentiments = []
75
+ for text in reviews['processed_text']:
76
+ if list(sentiment_model(text)[0].values())[0] == 'LABEL_1':
77
+ output = 'Positive'
78
+ else:
79
+ output = 'Negative'
80
+ sentiments.append(output)
81
+
82
+ reviews['sentiments'] = sentiments
83
+ st.markdown(':white[Output]')
84
+ st.dataframe(reviews, use_container_width=True)
85
+ # sns.countplot(reviews['sentiments'])
86
+ except KeyError:
87
+ st.markdown('Please :red[Re-run] the app')