Skip to content

Commit

Permalink
Merge pull request #175 from revanth1718/main
Browse files Browse the repository at this point in the history
Fix the streamlit app
  • Loading branch information
sanjay-kv authored Jun 8, 2024
2 parents 8de65ea + 115304d commit 947c303
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Binary file modified Web_app/__pycache__/utils.cpython-311.pyc
Binary file not shown.
46 changes: 46 additions & 0 deletions Web_app/pages/1_Movie_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
import json



st.sidebar.header("Upload your CSV!")
st.sidebar.write("Make sure your CSV file contains a 'review' or 'user_review' column.")

uploaded_file = st.sidebar.file_uploader("Choose a CSV file", type="csv")

with open('Movie_Animated.json', encoding='utf-8') as anim_source:
animation_data = json.load(anim_source)
st_lottie(animation_data, 1, True, True, "high", 150, -100)
Expand All @@ -30,6 +36,7 @@
</style>
""", unsafe_allow_html=True)


st.markdown('<div class="centered">', unsafe_allow_html=True)
st.markdown('<h1 class="yellow-headline">Movie Review Analysis</h1>', unsafe_allow_html=True)

Expand All @@ -45,6 +52,44 @@ def load_data(file):
try:
return pd.read_csv(file, encoding='utf-8')
except UnicodeDecodeError:

st.error("File encoding not supported. Please upload a CSV file with UTF-8 or Latin1 encoding.")
return None

if uploaded_file is not None:
reviews_df = load_data(uploaded_file)

if reviews_df is not None:
st.write("Data Preview:")
st.write(reviews_df.head())

st.write("Column Names:")
st.write(reviews_df.columns.tolist())

# Check for 'review' or 'user_review' columns
review_column = None
if 'review' in reviews_df.columns:
review_column = 'review'
elif 'user_review' in reviews_df.columns:
review_column = 'user_review'

if review_column:
st.write("Sentiment Analysis:")
sentiment_df, analyzed_df = analyze_reviews(reviews_df)
st.write(sentiment_df)

st.write("Analyzed DataFrame with Sentiments:")
st.write(analyzed_df.head())

st.write("Movie Recommendations:")
recommendations = recommend_movies(analyzed_df)
st.write(recommendations)
else:
st.error("The uploaded CSV file does not contain a 'review' or 'user_review' column.")
else:
st.write("Please upload a CSV file to proceed.")
st.write("Make sure your CSV file contains a 'review' or 'user_review' column.")

try:
return pd.read_csv(file, encoding='latin1')
except UnicodeDecodeError:
Expand Down Expand Up @@ -85,3 +130,4 @@ def load_data(file):
st.write("Please upload a CSV file to proceed.")

st.markdown('</div>', unsafe_allow_html=True)

2 changes: 0 additions & 2 deletions Web_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def analyze_reviews(df):
report = classification_report(y, y_pred, output_dict=True)
df['sentiment'] = y_pred


print("Analyzed DataFrame with Sentiments:")
print(df.head())

Expand All @@ -26,7 +25,6 @@ def analyze_reviews(df):
def recommend_movies(df):
positive_reviews = df[df['sentiment'] == 1]


print("DataFrame with Positive Reviews:")
print(positive_reviews.head())

Expand Down

0 comments on commit 947c303

Please sign in to comment.