diff --git a/Code/recommenderapp/app.py b/Code/recommenderapp/app.py index 4b9b50fa6..10f5a009f 100644 --- a/Code/recommenderapp/app.py +++ b/Code/recommenderapp/app.py @@ -1,7 +1,7 @@ """ Module for routing all calls from the frontend """ - +from Code.prediction_scripts.item_based import recommend_for_new_user import json import sys from search import Search @@ -10,7 +10,7 @@ from utils import send_email_to_user, beautify_feedback_data sys.path.append("../../") -from Code.prediction_scripts.item_based import recommend_for_new_user + app = Flask(__name__) app.secret_key = "secret key" diff --git a/Code/recommenderapp/utils.py b/Code/recommenderapp/utils.py index 3b588d3e7..4280dddfb 100644 --- a/Code/recommenderapp/utils.py +++ b/Code/recommenderapp/utils.py @@ -37,9 +37,9 @@ def create_colored_tags(genres): } tags = [] for genre in genres: - color = genre_colors.get(genre, '#CCCCCC') # Default color if not found - tag = f'{genre}' - tags.append(tag) + color = genre_colors.get(genre, '#CCCCCC') # Default color if not found + tag = f'{genre}' + tags.append(tag) return ' '.join(tags) @@ -87,23 +87,25 @@ def send_email_to_user(recipient_email, categorized_data): message['From'] = sender_email message['To'] = recipient_email message['Subject'] = subject - # Load the CSV file into a DataFrame movie_genre_df = pd.read_csv('../../data/movies.csv') # Create a dictionary to map movies to their genres movie_to_genres = {} - for index, row in movie_genre_df.iterrows(): + for row in movie_genre_df.rows(): movie = row['title'] genres = row['genres'].split('|') movie_to_genres[movie] = genres # Create the email message with HTML content html_content = c.EMAIL_HTML_CONTENT.format( - '\n'.join(f'
  • {movie} {create_colored_tags(movie_to_genres.get(movie, ["Unknown Genre"]))}

  • ' for movie in categorized_data['Liked']), - '\n'.join(f'
  • {movie} {create_colored_tags(movie_to_genres.get(movie, ["Unknown Genre"]))}

  • ' for movie in categorized_data['Disliked']), - '\n'.join(f'
  • {movie} {create_colored_tags(movie_to_genres.get(movie, ["Unknown Genre"]))}

  • ' for movie in categorized_data['Yet to Watch'])) + '\n'.join(f'
  • {movie} {create_colored_tags(movie_to_genres.get(movie, ["Unknown Genre"]))}

  • ' \ + for movie in categorized_data['Liked']), + '\n'.join(f'
  • {movie} {create_colored_tags(movie_to_genres.get(movie, ["Unknown Genre"]))}

  • ' \ + for movie in categorized_data['Disliked']), + '\n'.join(f'
  • {movie} {create_colored_tags(movie_to_genres.get(movie, ["Unknown Genre"]))}

  • ' \ + for movie in categorized_data['Yet to Watch'])) # Attach the HTML email body diff --git a/setup.py b/setup.py index d4e434253..173d84bf6 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,6 @@ +""" + Setup.py file for the code +""" import setuptools with open("README.md", "r", encoding="utf8") as fh: diff --git a/test/tests.py b/test/tests.py index 82d3fc552..d4b2c50b6 100644 --- a/test/tests.py +++ b/test/tests.py @@ -2,12 +2,12 @@ Test suite for recommender system """ +from Code.prediction_scripts.item_based import recommend_for_new_user import unittest import warnings import sys sys.path.append("../") -from Code.prediction_scripts.item_based import recommend_for_new_user warnings.filterwarnings("ignore")