Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paper - Kaylyn Cardella #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"python.pythonPath": "venv/bin/python"
}
122 changes: 122 additions & 0 deletions viewing_party/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
def create_movie(movie_title, genre, rating):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if movie_title == None or genre == None or rating == None:
new_movie = None
else:
new_movie = {
"title": movie_title,
"genre": genre,
"rating": rating
}

return new_movie

def add_to_watched(user_data, movie):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

user_data["watched"].append(movie)
return user_data

def add_to_watchlist(user_data, movie):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

user_data["watchlist"].append(movie)
return user_data

def watch_movie(user_data, title):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

for movie in user_data["watchlist"]:
if title == movie["title"]:
user_data["watchlist"].remove(movie)
user_data["watched"].append(movie)
return user_data

return user_data

def get_watched_avg_rating(user_data):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

ratings = []
average = 0

for movie in user_data["watched"]:
ratings.append(movie["rating"])
average = sum(ratings) / len(ratings)

return average

def get_most_watched_genre(user_data):
genres = dict()
# for every movie in the user's "watched" list,
# into the empty dictionary "genres", create a key == to a type of genre
# and assign a value to each individual key that keeps a count of how many
# times the key is found in the list
for movie in user_data["watched"]:
genres[movie["genre"]] = genres.get(movie["genre"], 0) + 1
Comment on lines +46 to +47
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clever way to build the frequency map.


if not genres:
return None

return (max(genres))

def get_unique_watched(user_data):
user_set = {movie["title"] for movie in user_data["watched"]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice LC


friend_set = set()
for friend in user_data["friends"]:
for movie in friend["watched"]:
friend_set.add(movie["title"])

unique_set = user_set - friend_set
Comment on lines +60 to +62
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A set and set difference, nicely done.


unique_titles = [{"title": title} for title in unique_set]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice learning comprehension


return unique_titles

def get_friends_unique_watched(user_data):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

user_set = {movie["title"] for movie in user_data["watched"]}

friends_set = set()
for friend in user_data["friends"]:
for movie in friend["watched"]:
friends_set.add(movie["title"])
Comment on lines +72 to +74
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This segment seems repeated, could you create or use a helper method?


friends_unique_movies = [{"title": movie} for movie in friends_set if movie not in user_set]

return friends_unique_movies

def get_available_recs(user_data):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

friends_watched = []
for friend in user_data["friends"]:
for entry in friend["watched"]:
friends_watched.append(entry)

for movie in friends_watched:
if friends_watched.count(movie) > 1:
friends_watched.remove(movie)

recommendations = [movie for movie in friends_watched if movie["host"] in \
user_data["subscriptions"]]

return recommendations

def get_new_rec_by_genre(user_data):
most_popular = get_most_watched_genre(user_data)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good reuse of an existing method


user_watched = [movie for movie in user_data["watched"]]

friends_watched = []
for friend in user_data["friends"]:
for entry in friend["watched"]:
friends_watched.append(entry)

recommendations = [movie for movie in friends_watched \
if movie not in user_watched and movie["genre"] == most_popular]

return recommendations

def get_rec_from_favorites(user_data):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

friends_watched = []
for friend in user_data["friends"]:
for movie in friend["watched"]:
friends_watched.append(movie)

recommendations = [movie for movie in user_data["favorites"]\
if movie not in friends_watched]

return recommendations