DEV Community

DouglasG98
DouglasG98

Posted on

Process to Create a Movie Recommender in the Terminal

This post is about the process of how I coded a Movie Recommender program in the terminal for anyone that is interested. :)

Pre-Planning:

  • Going into this project, I knew the main concept that I wanted to work around was using class and different data structures in python. Before starting I needed to plan for the class of the data, source of the data, the user interface and the search algorithm.

Data Structure for database:

  • Each movie in the database is a node containing a dictionary with key: value pairs that correspond to information about the movie. The main attributes of the class were .name, .genre, .rating, .actors, and .synopsis. As a movie can have multiple genres and actors, these attributes store data in lists.

Data Source:

  • The source of the data was from the movie review website - RottonTomatoes. The data was compiled into a CSV file and initialized into Movie class objects whenever the program starts.

User Interface:

  • The user interface was where most of the coding was done. I found that using flowcharts to visualize program flow made writing the code many times easier. The user interface is programmed to ask users what filters they would like to add to the search. All user preference is saved into a separate dictionary and used in the search algorithm. There are definitely more improvements to be done with the interface, however, it should work just fine and should be comprehensible enough for users to navigate.

Search Algorithm:

  • The search algorithm is a simple linear search algorithm that will first add all movies that fits the rating and actors criteria set by the users. After that, the algorithm iterates through the list of added movies and remove all that does not fit the genre criteria. In essences, it will display all movies with any of the actors in the filter and any rating within the range of the filter. However, only movies with all genre filters will remain. The search algorithm has a time-complexity and space-complexity of O(n).

If you are interested, you can find my code here at GitHub.

Top comments (0)