Skip to content

Commit 56536b0

Browse files
committed
Updated Movie Analysis Page
1 parent ab8afea commit 56536b0

File tree

5 files changed

+82
-44
lines changed

5 files changed

+82
-44
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.e

Web_app/Movie_Animated.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
-13 Bytes
Binary file not shown.

Web_app/pages/1_Movie_Analysis.py

Lines changed: 79 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,87 @@
11
import streamlit as st
22
import pandas as pd
33
from utils import analyze_reviews, recommend_movies
4+
from streamlit_lottie import st_lottie
5+
import json
46

5-
st.title("Movie Review Analysis")
67

7-
st.sidebar.header("Upload your CSV!")
8-
uploaded_file = st.sidebar.file_uploader("Choose a CSV file", type="csv")
8+
with open('Movie_Animated.json', encoding='utf-8') as anim_source:
9+
animation_data = json.load(anim_source)
10+
st_lottie(animation_data, 1, True, True, "high", 150, -100)
11+
# Adding custom CSS to centralize components and style the headline
12+
st.markdown("""
13+
<style>
14+
.centered {
15+
display: flex;
16+
justify-content: center;
17+
align-items: center;
18+
flex-direction: column;
19+
}
20+
.centered .stFileUploader, .centered .stButton, .centered .stDataFrame, .centered .stTable {
21+
width: 80%;
22+
}
23+
.yellow-headline {
24+
color: yellow;
25+
text-align: center;
26+
}
27+
.line {
28+
margin: 20px 0;
29+
}
30+
</style>
31+
""", unsafe_allow_html=True)
932

10-
def load_data(file):
11-
try:
12-
return pd.read_csv(file, encoding='utf-8')
13-
except UnicodeDecodeError:
33+
st.markdown('<div class="centered">', unsafe_allow_html=True)
34+
st.markdown('<h1 class="yellow-headline">Movie Review Analysis</h1>', unsafe_allow_html=True)
35+
36+
# Adding slider to control the length of the line
37+
line_length = st.write("__________________________________________________________________")
38+
39+
40+
41+
uploaded_file = st.file_uploader("Upload your CSV file", type="csv")
42+
43+
if st.button('Enter'):
44+
def load_data(file):
1445
try:
15-
return pd.read_csv(file, encoding='latin1')
46+
return pd.read_csv(file, encoding='utf-8')
1647
except UnicodeDecodeError:
17-
st.error("File encoding not supported. Please upload a CSV file with UTF-8 or Latin1 encoding.")
18-
return None
19-
20-
if uploaded_file is not None:
21-
reviews_df = load_data(uploaded_file)
22-
23-
if reviews_df is not None:
24-
st.write("Data Preview:")
25-
st.write(reviews_df.head())
26-
27-
st.write("Column Names:")
28-
st.write(reviews_df.columns.tolist())
29-
30-
# Check for 'review' or 'user-review' columns
31-
review_column = None
32-
if 'review' in reviews_df.columns:
33-
review_column = 'review'
34-
elif 'user_review' in reviews_df.columns:
35-
review_column = 'user_review'
36-
37-
if review_column:
38-
st.write("Sentiment Analysis:")
39-
sentiment_df, analyzed_df = analyze_reviews(reviews_df, review_column)
40-
st.write(sentiment_df)
41-
42-
st.write("Analyzed DataFrame with Sentiments:")
43-
st.write(analyzed_df.head())
44-
45-
st.write("Movie Recommendations:")
46-
recommendations = recommend_movies(analyzed_df)
47-
st.write(recommendations)
48-
else:
49-
st.error("The uploaded CSV file does not contain a 'review' or 'user_review' column.")
50-
else:
51-
st.write("Please upload a CSV file to proceed.")
48+
try:
49+
return pd.read_csv(file, encoding='latin1')
50+
except UnicodeDecodeError:
51+
st.error("File encoding not supported. Please upload a CSV file with UTF-8 or Latin1 encoding.")
52+
return None
53+
54+
if uploaded_file is not None:
55+
reviews_df = load_data(uploaded_file)
56+
57+
if reviews_df is not None:
58+
st.write("Data Preview:")
59+
st.write(reviews_df.head())
60+
61+
st.write("Column Names:")
62+
st.write(reviews_df.columns.tolist())
63+
64+
# Check for 'review' or 'user-review' columns
65+
review_column = None
66+
if 'review' in reviews_df.columns:
67+
review_column = 'review'
68+
elif 'user_review' in reviews_df.columns:
69+
review_column = 'user_review'
70+
71+
if review_column:
72+
st.write("Sentiment Analysis:")
73+
sentiment_df, analyzed_df = analyze_reviews(reviews_df)
74+
st.write(sentiment_df)
75+
76+
st.write("Analyzed DataFrame with Sentiments:")
77+
st.write(analyzed_df.head())
78+
79+
st.write("Movie Recommendations:")
80+
recommendations = recommend_movies(analyzed_df)
81+
st.write(recommendations)
82+
else:
83+
st.error("The uploaded CSV file does not contain a 'review' or 'user_review' column.")
84+
else:
85+
st.write("Please upload a CSV file to proceed.")
86+
87+
st.markdown('</div>', unsafe_allow_html=True)

Web_app/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ beautifulsoup4
33
requests
44
pandas
55
scikit-learn
6-
pickle
6+
77
selenium

0 commit comments

Comments
 (0)