def print_question(data, labels, user_ids, data_dicts):
    option = 0
    movies, genres = get_movie_genres(data, labels)
    while(option != 2 and option != 1):
        print ('Are you registered in the system? \n1 for Yes \n2 for No')
        try:
            option = int(input())
        except:
            print 'Please try Again, we could not understand the input'
            continue
    if option == 1:
        new_id = 0
        while not new_id in user_ids:
            print ('Enter id assigned: ')
            try:
                new_id = int(input())
            except:
                print 'Please Enter a correct Id'
                continue
        recomendations, data_dicts =  existing_user(movies=movies, user_id=new_id,
                                        ranks=data_dicts[new_id].keys(), 
                                        data_dicts=data_dicts)
    else:
        new_id = max(user_ids) + 1
        recomendations, data_dicts = existing_user(movies=movies, user_id=new_id,
                                                   data_dicts=data_dicts)
    print 'We recomend the next movies for you:'
    for x in recomendations[:5]:
        print x
Exemplo n.º 2
0
from read_data import read_file, get_ratexuser, get_movie_genres
from similarity import recommend
from user_personalization import print_question

data, labels = read_file()

# Get all the movie titles just one time
movies, genres = get_movie_genres(data, labels)

# separate the users by Id and then take just the ranking for each movie
data_dicts, user_ids = get_ratexuser(data)

print_question(data, labels, user_ids, data_dicts)