Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,30 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import seaborn as sns
|
| 3 |
-
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
|
| 7 |
sentiment_model = pipeline(model="ashok2216/gpt2-amazon-sentiment-classifier")
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
# for
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# else:
|
| 16 |
-
# output = 'Negative'
|
| 17 |
-
# sentiments.append(output)
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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'])
|