Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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(':
|
| 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("
|
| 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 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
sentiments
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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')
|