File size: 1,008 Bytes
2d0356a
7901fc5
 
94c0eb7
7901fc5
c34d627
7901fc5
7886342
7901fc5
2bb3a11
94c0eb7
 
 
7901fc5
94c0eb7
 
 
 
7901fc5
94c0eb7
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pandas as pd
import streamlit as st
import seaborn as sns
from data_cleaning import preprocess
from transformers import pipeline
from data_integration import scrape_all_pages

sentiment_model = pipeline(model="ashok2216/gpt2-amazon-sentiment-classifier")

# Example usage:-
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'
url = st.text_input("Amazon product link", sample_url)
st.write("The current movie title is", url)

all_reviews = scrape_all_pages(url)
# Convert to DataFrame for further analysis
reviews = pd.DataFrame(all_reviews)
processed_text = reviews[content]

# st.markdown(sentiment_model(['It is Super!']))

sentiments = []
for text in processed_text:
    if list(sentiment_model(text)[0].values())[0] == 'LABEL_1':
        output = 'Positive'
    else:
        output = 'Negative'
    sentiments.append(output)

df['sentiments'] = sentiments
sns.countplot(df['sentiments'])