-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecommender.h
More file actions
68 lines (57 loc) · 1.63 KB
/
Recommender.h
File metadata and controls
68 lines (57 loc) · 1.63 KB
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
#ifndef RECOMMENDER_INCLUDED
#define RECOMMENDER_INCLUDED
#include <string>
#include <vector>
#include "treemm.h"
#include "UserDatabase.h"
#include "MovieDatabase.h"
#include "Movie.h"
#include <map>
#include <set>
struct MovieAndRank
{
MovieAndRank(const std::string& id, int score)
: movie_id(id), compatibility_score(score)
{}
std::string movie_id;
int compatibility_score;
};
class Recommender
{
public:
Recommender(const UserDatabase& user_database,
const MovieDatabase& movie_database);
std::vector<MovieAndRank> recommend_movies(const std::string& user_email,
int movie_count) const;
private:
struct Rec_Movie
{
int curr_score;
float curr_rating;
std::string curr_title;
Rec_Movie(int score, float rating, std::string title)
{
curr_score = score;
curr_rating = rating;
curr_title = title;
}
bool operator<(const Rec_Movie &b) const
{
if (curr_score != b.curr_score)
{
return curr_score > b.curr_score;
}
else if (curr_rating != b.curr_rating)
{
return curr_rating > b.curr_rating;
}
else
{
return curr_title < b.curr_title;
}
}
};
const UserDatabase* m_udb;
const MovieDatabase* m_mb;
};
#endif // RECOMMENDER_INCLUDED