-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
127 lines (116 loc) · 4.14 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "UserDatabase.h"
#include "User.h"
#include <iostream>
#include <string>
#include "Recommender.h"
using namespace std;
//////////////////////////i/////////////////////////////////////////////////////
//
// You are free to do whatever you want with this file, since you won't
// be turning it in. Presumably, you will make changes to help you test
// your classes. For example, you might try to implement only some User
// member functions to start out with, and so replace our main routine with
// one that simply creates a User and verifies that the member functions you
// implemented work correctly.
//
//////////////////////////i/////////////////////////////////////////////////////
// If your program is having trouble finding these files. replace the
// string literals with full path names to the files. Also, for test
// purposes, you may want to create some small, simple user and movie
// data files to makde debuggiing easier, so you can replace the string
// literals with the names of those smaller files.
const string USER_DATAFILE = "users.txt";
const string MOVIE_DATAFILE = "movies.txt";
//int main()
//{
// UserDatabase udb;
// if (0&&!udb.load(USER_DATAFILE)) // In skeleton, load always return false
// {
// cout << "Failed to load user data file " << USER_DATAFILE << "!" << endl;
// return 1;
// }
// for (;;)
// {
// cout << "Enter user email address (or quit): ";
// string email;
// getline(cin, email);
// if (email == "quit")
// return 0;
// User* u = udb.get_user_from_email(email);
// if (u == nullptr)
// cout << "No user in the database has that email address." << endl;
// else
// cout << "Found " << u->get_full_name() << endl;
// }
//}
#include "treemm.h"
//int main()
//{
// TreeMultimap <string, int> tree;
// tree.insert("ryan", 40);
// TreeMultimap <string, int>:: Iterator it = tree.find("ryan");
// cout << it.get_value();
//}
//int main()
//{
// UserDatabase data;
// data.load("/Users/ryanvu/Downloads/miniUsers.txt");
// User* user = data.get_user_from_email("[email protected]");
// cout<< user->get_full_name() <<endl;
//}
#include "MovieDatabase.h"
#include "Movie.h"
//int main()
//{
// MovieDatabase movies;
// movies.load("/Users/ryanvu/Downloads/miniMovies.txt");
// Movie* specificMovie = movies.get_movie_from_id("ID10782");
// cout<< specificMovie->get_title()<<endl;
// vector<Movie*> moviesWithDirector = movies.get_movies_with_director("M. Raja");
// vector<Movie*> moviesWithActor = movies.get_movies_with_actor("Ben Shapiro");
// vector<Movie*> moviesWithGenre = movies.get_movies_with_genre("Documentary");
// for (int i =0; i<moviesWithDirector.size(); i++)
// {
// cout<< (moviesWithDirector.at(i))->get_title()<<endl;
// }
// for (int i =0; i<moviesWithActor.size(); i++)
// {
// cout<< (moviesWithActor.at(i))->get_title()<<endl;
// }
// for (int i =0; i<moviesWithGenre.size(); i++)
// {
// cout<< (moviesWithGenre.at(i))->get_title()<<endl;
// }
//}
void findMatches(Recommender& r,
const MovieDatabase& md,
const string& user_email,
int num_recommendations)
{
// get up to ten movie recommendations for the user
vector<MovieAndRank> recommendations = r.recommend_movies(user_email, num_recommendations);
if (recommendations.empty())
cout << "We found no movies to recommend :(.\n";
else {
for (int i = 0; i < recommendations.size(); i++)
{
const MovieAndRank& mr = recommendations[i];
Movie* m = md.get_movie_from_id(mr.movie_id);
cout << i << ". " << m->get_title() << " ("
<< m->get_release_year() << ")\n Rating: "
<< m->get_rating() << "\n Compatibility Score: "
<< mr.compatibility_score << "\n";
}
}
}
//"/Users/ryanvu/Downloads/Pnetphlix/miniUsers.txt"
//"/Users/ryanvu/Downloads/Pnetphlix/miniMovies.txt"
int main()
{
MovieDatabase movies;
movies.load("/Users/ryanvu/Downloads/Pnetphlix/miniMovies.txt");
UserDatabase data;
data.load("/Users/ryanvu/Downloads/Pnetphlix/miniUsers.txt");
Recommender rec (data, movies);
findMatches(rec, movies, "[email protected]", 10);
}