-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathManager.h
286 lines (249 loc) · 5.75 KB
/
Manager.h
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#ifndef _manager_head
#define _manager_head
#include"tools.h"
#include<queue>
class NonLeafAuthor;
class Paper;
class node;
class Author;
class Affiliation;
class Author;
class Venue;
class Manager;
class AuthorManager;
class PaperManager;
class KeywordManager;
class VenueManager;
class Manager {
};
typedef unsigned int AUTHOR_NUMBER_TYPE ;
struct vpair {
int vi;
int vj;
float score;
bool operator <(const vpair &) const;
vpair(int i,int j, float s) {
vi = i;
vj = j;
score = s;
}
vpair() {
vi = -1;
vj = -1;
score = -1;
}
};
typedef struct vpair spair;
typedef struct {
Author *ai, *aj;
float simi;
}aps, apair;
struct author_pair_sim {
int ai;
int aj;
float score;
bool operator <(const author_pair_sim &c) const {
if (score<c.score)
return false;
if (score>c.score)
return true;
return false;
}
author_pair_sim(int i, int j, float s) {
ai = i;
aj = j;
score = s;
}
author_pair_sim() {
ai = -1;
aj = -1;
score = -1;
}
};
struct AuthorForestLayer{
//NonLeafAuthor ** authors;
//int authorsize;
author_pair_sim* apairs;
int apairLen;
vector<NonLeafAuthor *> authors;
};
class AuthorManager :public Manager {
private:
AUTHOR_NUMBER_TYPE AID;
vector<string> fnames;
float logs[1024*8];
float asum, vsum, tsum;
int namesize;
vector<Author*>* leafAuthorVectors;
vector<AuthorForestLayer>* author_forests;//each name corresponding to a forest. each layer of the forests are stored by list.
AuthorForestLayer *outputLayers; // output after clustering_single
double MINSIM, MAXSIM;
//map<int,ofstream> s2fout;
int *paperNumber;
bool outputclusters;// if output cluster nor not
double Thres1;
vector<int> min_author_nums;
float calSimSingle(NonLeafAuthor *, NonLeafAuthor *, double);
float calSim(NonLeafAuthor *, NonLeafAuthor *, double);
void update(queue<int> & que, bool * flags, NonLeafAuthor *);
bool isSim(Author *ai, Author *aj);
public:
int getMinAuthorNums(int nid);
void calInitAuthorNumbers();
//debug
void outputInitAuthorNumber(string & fpath);
void initSim();
int getInitAuthorNumber(int id);
void outputAllCluster(string path);
void init();
void init(bool);
void init(double, double);
void setThres(double);
void clear();
AuthorManager();
~AuthorManager();
Author* addAuthor(const string &name, Paper * pa);
bool outpuCoauthorSize(string);
void getcluster(list<Author *>*, const int*, vector<vector<Author *>*> &);
void createAtom();
void setAlltoOld();
void calRs();
void iterate();
void clusterSingle();
void clusterSingle(int);
int currentSize();
int initSize();
AuthorForestLayer* getClusters(string name);
void outputCluster(ofstream&, int nid);
// for incremental
public:
void set1stLayerNbrsUpdated();
void inc_iterate();
void inc_createAtom();
};
class KeywordManager : public Manager {
private:
//temp
map<int,string> id2name;
double MINSIM;
set<string> stopwords, stopwords2;
map<string, int> *kws2id;
string *names;
int unseenid;
//store the similairty
int kid;
int ksize;
spair * pairsimi;
int *indexs;
public:
int *sizes;
private:
void readstopwords(const string&, const string&);
void readsimi(const string &, vector<spair>&);
void readfile(const string &);
public:
int getID(string);
void arraylize();
void init(double, const string&, const string&, const string&, const string&);
int getSize(string);
void addsimi(map<int, float> &, map<int, float> &);
string getName(int id);
KeywordManager();
~KeywordManager();
void clear();
int size();
};
class PaperManager : public Manager {
public:
map<string, int> title2id;
map<int, Paper*> id2paper;
vector<string> titles;
unsigned int pid;
static int index;
vector<Paper*> allpaper;
public:
void clear();
~PaperManager();
void init(const string & fpath);
void initMAG(const string & fpath);
void addPaper(Paper * pa);
private:
int MAGID;
void readIEEE(const string &);
void readCitation(const string &);
void readHomepage(const string &);
void readMAG(const string &, const string &);
void readfile(const string &);
};
class VenueManager : public Manager {
private:
//ofstream *fmiss;
map<string, int> *vs2id;
map<int, string> id2name;
//Venue ** ves;
vpair * pairsimi;
int vsize;
int maxid;
void readfile(string &);
void readsimi(string &, vector<vpair>&);
int *indexs;
int* sizes;
int unseenid;
double VMINSIM;
public:
//set<string>* missvenue;
void clear();
void fileClose();
int getID(string);
void init(double, string &, string &);
void init(string &, string &);
VenueManager();
~VenueManager();
//Venue* getVenue(string name, Paper * pa);
int size();
int getsize(int);
//void addsimi(map<int, float>&);
void addsimi(map<int, float>&, map<int, float>&);
string getname(int id);
bool isSim(int id1, int id2);
};
class NameManager {
private:
//ofstream *fmiss;
//scale2 for maxnum
double scale, scale2;
map<string, int> name2id;
vector<int> id2size;
vector<float> id2amr;
vector<string> id2name;
int id;
bool *flags;
set<string> chnames;
vector<bool> id2cn;
void readfile(string &, string &);
public:
vector<set<int>> id_2_coauthor_ids;
void fileClose();
NameManager();
~NameManager();
void estimateAuthorNumber(AuthorManager &am);
void addCoauthor(Paper*);
void init(string &, string &);
int getNameSize();
int getNameId(string);
float getAmb(int);
bool isCn(int);
string getName(int);
void output();
void combineAmr();
int size();
void clear();
};
class AffiliationManager {
public:
void init(string &);
int getcount(string&);
private:
map<string, int> aff2count;
};
#endif