-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMethodY.h
More file actions
80 lines (67 loc) · 1.68 KB
/
MethodY.h
File metadata and controls
80 lines (67 loc) · 1.68 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
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef METHODY_H
#define METHODY_H
#include <string>
#include <fstream>
#include <iostream>
#include <list>
#include <vector>
#include <set>
#include <map>
class Action
{
private:
int __user_id;
int __item_id;
double __score;
public:
Action(int ui,int ii,double s);
int userID() const;
int itemID() const;
double score() const;
};
class Item
{
private:
int __id; // the id of the item
int __counts; // the number that the item is visited
std::vector<int> __r_scores; // the co-visitation
bool __id_set;
std::map<int,int> __co_counts;
public:
Item();
Item(int id);
void setID(int id);
bool idSet() const;
int id() const{return __id;}
int& counts(){return __counts;}
std::map<int,int>& coCounts(){return __co_counts;}
};
// Item matrix stores the related information
class ItemMatrix
{
private:
std::map<int,std::map<int,double> > __mat;
};
class User
{
private:
int __id;
int __counts;
std::list<int> __items;
bool __id_set;
public:
User();
User(int id);
std::list<int>& items();
const std::list<int>& items() const{return __items;}
void setID(int id);
bool idSet() const;
};
void firstRoundReadFile(const std::string& filename,
int num, // the number of elements in a row
std::list<Action>& actions);
void constructUser(const std::list<Action>& acts, std::vector<User> &users, std::map<int,int>& idmap);
void constructItem(const std::list<Action>& acts, std::vector<Item> &items, std::map<int,int>& idmap);
void fixItems( std::vector<User>& users,const std::vector<Item>& items,const std::map<int,int>& itemmap);
void computeCoVisitation(const std::vector<User>& users, std::vector<Item>& items);
#endif