Showing
10 changed files
with
140 additions
and
16 deletions
... | @@ -159,18 +159,53 @@ void GraphItem::read_more() | ... | @@ -159,18 +159,53 @@ void GraphItem::read_more() |
159 | year = stoi(year_str); | 159 | year = stoi(year_str); |
160 | node_title_map[*vi] = title; | 160 | node_title_map[*vi] = title; |
161 | node_year_map[*vi] = year; | 161 | node_year_map[*vi] = year; |
162 | -#endif // CITATION_COUNT | 162 | + |
163 | - | ||
164 | //카테고리 계산 및 accuracy 계산 | 163 | //카테고리 계산 및 accuracy 계산 |
165 | //--> case insensitive | 164 | //--> case insensitive |
166 | - | 165 | + double max_acc = -1; |
166 | + int max_acc_idx; | ||
167 | + vector<string> title_words; | ||
168 | + for (int j = 0; j < keywords.size(); ++j) { | ||
169 | + auto& paper_category = keywords[j]; | ||
170 | + const int& category_sz = paper_category.size(); | ||
171 | + int match_cnt = 0; | ||
172 | + | ||
173 | + //논문제목을 word들로 분할 | ||
174 | + boost::split(title_words, title, boost::is_any_of(" "), boost::token_compress_on); | ||
175 | + for (auto& keyword : paper_category) { | ||
176 | + //각 word마다 수행 | ||
177 | + for (auto& word: title_words) { | ||
178 | + if (boost::iequals(word, keyword)) { | ||
179 | + ++match_cnt; | ||
180 | + break; | ||
181 | + } | ||
182 | + } | ||
183 | + } | ||
184 | + | ||
185 | + double acc = (double)match_cnt / category_sz; | ||
186 | + if (max_acc < acc && match_cnt != 0) { | ||
187 | + max_acc = acc; | ||
188 | + max_acc_idx = j; | ||
189 | + } | ||
190 | + } | ||
191 | + if (max_acc_idx == keywords.size() - 1 | ||
192 | + && max_acc != -1) { | ||
193 | + //no category detected | ||
194 | + node_category_map[*vi] = CS_OH; | ||
195 | + node_category_accuracy_map[*vi] = 0.0; | ||
196 | + } | ||
197 | + else { | ||
198 | + node_category_map[*vi] = max_acc_idx; | ||
199 | + node_category_accuracy_map[*vi] = max_acc; | ||
200 | + } | ||
201 | + | ||
202 | + | ||
203 | +#endif // CITATION_COUNT | ||
167 | } else { | 204 | } else { |
168 | //Author | 205 | //Author |
169 | boost::put(vertex_type, *graph, *vi, NODE_TYPE::NODE_AUTHOR); | 206 | boost::put(vertex_type, *graph, *vi, NODE_TYPE::NODE_AUTHOR); |
170 | } | 207 | } |
171 | 208 | ||
172 | - | ||
173 | - | ||
174 | //counter | 209 | //counter |
175 | //printf("%d end: %s\n", i, node_label.c_str()); | 210 | //printf("%d end: %s\n", i, node_label.c_str()); |
176 | ++i; | 211 | ++i; |
... | @@ -255,10 +290,12 @@ void GraphItem::read_more() | ... | @@ -255,10 +290,12 @@ void GraphItem::read_more() |
255 | //make node item and push it to list | 290 | //make node item and push it to list |
256 | NodeItem *node; | 291 | NodeItem *node; |
257 | if (nt == NODE_TYPE::NODE_PAPER) { | 292 | if (nt == NODE_TYPE::NODE_PAPER) { |
258 | - node = new NodeItem(p[0], p[1], QColor(Qt::darkGreen), QString(name.c_str()), nt); | 293 | + node = new NodeItem(p[0], p[1], QColor(Qt::darkGreen), QString(name.c_str()), nt, |
294 | + node_category_map[*vi], node_category_accuracy_map[*vi], node_year_map[*vi]); | ||
259 | } | 295 | } |
260 | else { | 296 | else { |
261 | - node = new NodeItem(p[0], p[1], QColor(Qt::green), QString(name.c_str()), nt); | 297 | + node = new NodeItem(p[0], p[1], QColor(Qt::green), QString(name.c_str()), nt, |
298 | + -1, -1, -1); | ||
262 | } | 299 | } |
263 | node->setPos(QPointF(p[0], p[1])); | 300 | node->setPos(QPointF(p[0], p[1])); |
264 | nodeList << node; | 301 | nodeList << node; |
... | @@ -965,6 +1002,17 @@ void GraphItem::topk_with_pagerank() { | ... | @@ -965,6 +1002,17 @@ void GraphItem::topk_with_pagerank() { |
965 | delete[] topk_arr; | 1002 | delete[] topk_arr; |
966 | } | 1003 | } |
967 | 1004 | ||
1005 | +void GraphItem::category_visualize() { | ||
1006 | + //전체노드 색 변경 | ||
1007 | + for (auto& n : nodeList) { | ||
1008 | + n->setColor(Qt::lightGray); | ||
1009 | + | ||
1010 | + if (n->getType() == NODE_TYPE::NODE_AUTHOR) continue; | ||
1011 | + | ||
1012 | + n->setColor(QColor(category_colors[n->getCategory()].c_str())); | ||
1013 | + } | ||
1014 | +} | ||
1015 | + | ||
968 | void GraphItem::reset_color() | 1016 | void GraphItem::reset_color() |
969 | { | 1017 | { |
970 | for (auto& n: nodeList) { | 1018 | for (auto& n: nodeList) { | ... | ... |
... | @@ -8,7 +8,7 @@ | ... | @@ -8,7 +8,7 @@ |
8 | using namespace std; | 8 | using namespace std; |
9 | using namespace boost; | 9 | using namespace boost; |
10 | 10 | ||
11 | -//#define CITATION_COUNT | 11 | +#define CITATION_COUNT |
12 | 12 | ||
13 | class GraphItem | 13 | class GraphItem |
14 | : public QGraphicsItem | 14 | : public QGraphicsItem |
... | @@ -33,6 +33,7 @@ public: | ... | @@ -33,6 +33,7 @@ public: |
33 | //void topK_using_custom_score(); | 33 | //void topK_using_custom_score(); |
34 | void find_shortest_path(); | 34 | void find_shortest_path(); |
35 | void topk_with_pagerank(); | 35 | void topk_with_pagerank(); |
36 | + void category_visualize(); | ||
36 | void reset_color(); | 37 | void reset_color(); |
37 | 38 | ||
38 | //test | 39 | //test | ... | ... |
... | @@ -55,6 +55,9 @@ void MainWindow::createActions() | ... | @@ -55,6 +55,9 @@ void MainWindow::createActions() |
55 | topkWithPagerankAct = new QAction(tr("topK with pagerank"), this); | 55 | topkWithPagerankAct = new QAction(tr("topK with pagerank"), this); |
56 | topkWithPagerankAct->setStatusTip(tr("highlight which is in top k pagerank in whole graph")); | 56 | topkWithPagerankAct->setStatusTip(tr("highlight which is in top k pagerank in whole graph")); |
57 | connect(topkWithPagerankAct, &QAction::triggered, this, &MainWindow::topk_with_pagerank); | 57 | connect(topkWithPagerankAct, &QAction::triggered, this, &MainWindow::topk_with_pagerank); |
58 | + categoryVisualizeAct = new QAction(tr("category visualize"), this); | ||
59 | + categoryVisualizeAct->setStatusTip(tr("category visualization")); | ||
60 | + connect(categoryVisualizeAct, &QAction::triggered, this, &MainWindow::category_visualize); | ||
58 | 61 | ||
59 | resetColorAct = new QAction(tr("Reset colors"), this); | 62 | resetColorAct = new QAction(tr("Reset colors"), this); |
60 | resetColorAct->setStatusTip(tr("Reset all node's color")); | 63 | resetColorAct->setStatusTip(tr("Reset all node's color")); |
... | @@ -77,6 +80,7 @@ void MainWindow::createMenus() | ... | @@ -77,6 +80,7 @@ void MainWindow::createMenus() |
77 | actionMenu->addAction(topKWithTargetAct); | 80 | actionMenu->addAction(topKWithTargetAct); |
78 | actionMenu->addAction(findShortestPathAct); | 81 | actionMenu->addAction(findShortestPathAct); |
79 | actionMenu->addAction(topkWithPagerankAct); | 82 | actionMenu->addAction(topkWithPagerankAct); |
83 | + actionMenu->addAction(categoryVisualizeAct); | ||
80 | 84 | ||
81 | actionMenu->addAction(resetColorAct); | 85 | actionMenu->addAction(resetColorAct); |
82 | 86 | ||
... | @@ -117,6 +121,10 @@ void MainWindow::topk_with_pagerank() { | ... | @@ -117,6 +121,10 @@ void MainWindow::topk_with_pagerank() { |
117 | graphWidget->topk_with_pagerank(); | 121 | graphWidget->topk_with_pagerank(); |
118 | } | 122 | } |
119 | 123 | ||
124 | +void MainWindow::category_visualize() { | ||
125 | + graphWidget->category_visualize(); | ||
126 | +} | ||
127 | + | ||
120 | void MainWindow::reset_color() | 128 | void MainWindow::reset_color() |
121 | { | 129 | { |
122 | graphWidget->reset_color(); | 130 | graphWidget->reset_color(); | ... | ... |
... | @@ -27,6 +27,7 @@ private: | ... | @@ -27,6 +27,7 @@ private: |
27 | QAction *resetColorAct; | 27 | QAction *resetColorAct; |
28 | QAction *topkWithPagerankAct; | 28 | QAction *topkWithPagerankAct; |
29 | QAction *findShortestPathAct; | 29 | QAction *findShortestPathAct; |
30 | + QAction *categoryVisualizeAct; | ||
30 | 31 | ||
31 | //test | 32 | //test |
32 | QMenu *testMenu; | 33 | QMenu *testMenu; |
... | @@ -43,6 +44,7 @@ private slots: | ... | @@ -43,6 +44,7 @@ private slots: |
43 | void topK_with_target(); | 44 | void topK_with_target(); |
44 | void find_shortest_path(); | 45 | void find_shortest_path(); |
45 | void topk_with_pagerank(); | 46 | void topk_with_pagerank(); |
47 | + void category_visualize(); | ||
46 | void reset_color(); | 48 | void reset_color(); |
47 | //test | 49 | //test |
48 | void test(); | 50 | void test(); | ... | ... |
... | @@ -22,7 +22,8 @@ void NodeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) | ... | @@ -22,7 +22,8 @@ void NodeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) |
22 | { | 22 | { |
23 | } | 23 | } |
24 | 24 | ||
25 | -NodeItem::NodeItem(double x, double y, QColor color, QString label, int type) | 25 | +NodeItem::NodeItem(double x, double y, QColor color, QString label, int type, int category, |
26 | + double _accuracy, int year) | ||
26 | { | 27 | { |
27 | //node constructor | 28 | //node constructor |
28 | this->x = x; | 29 | this->x = x; |
... | @@ -30,6 +31,9 @@ NodeItem::NodeItem(double x, double y, QColor color, QString label, int type) | ... | @@ -30,6 +31,9 @@ NodeItem::NodeItem(double x, double y, QColor color, QString label, int type) |
30 | this->color = color; | 31 | this->color = color; |
31 | this->label = label; | 32 | this->label = label; |
32 | this->type = type; | 33 | this->type = type; |
34 | + this->category = category; | ||
35 | + this->category_accuracy = _accuracy; | ||
36 | + this->year = year; | ||
33 | setZValue(1); | 37 | setZValue(1); |
34 | 38 | ||
35 | //setFlags(ItemIsSelectable | ItemIsMovable); | 39 | //setFlags(ItemIsSelectable | ItemIsMovable); | ... | ... |
... | @@ -12,6 +12,9 @@ private: | ... | @@ -12,6 +12,9 @@ private: |
12 | QColor color; | 12 | QColor color; |
13 | QString label; | 13 | QString label; |
14 | int type; | 14 | int type; |
15 | + int category; | ||
16 | + double category_accuracy; | ||
17 | + int year; | ||
15 | 18 | ||
16 | protected: | 19 | protected: |
17 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override; | 20 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override; |
... | @@ -19,11 +22,15 @@ protected: | ... | @@ -19,11 +22,15 @@ protected: |
19 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; | 22 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; |
20 | 23 | ||
21 | public: | 24 | public: |
22 | - NodeItem(double x, double y, QColor color, QString label, int type); | 25 | + NodeItem(double x, double y, QColor color, QString label, int type, int category, |
26 | + double _accuracy, int year); | ||
23 | 27 | ||
24 | //getter setter | 28 | //getter setter |
25 | QString getLabel() {return label;} | 29 | QString getLabel() {return label;} |
26 | int getType() { return type; } | 30 | int getType() { return type; } |
31 | + int getCategory() { return category; } | ||
32 | + double getAccuracy() { return category_accuracy; } | ||
33 | + int getYear() { return year; } | ||
27 | void setColor(QColor color) {this->color=color;} | 34 | void setColor(QColor color) {this->color=color;} |
28 | 35 | ||
29 | QRectF boundingRect() const override; | 36 | QRectF boundingRect() const override; | ... | ... |
... | @@ -92,9 +92,6 @@ | ... | @@ -92,9 +92,6 @@ |
92 | <ClCompile Include="json_processor.cpp"> | 92 | <ClCompile Include="json_processor.cpp"> |
93 | <Filter>Source Files</Filter> | 93 | <Filter>Source Files</Filter> |
94 | </ClCompile> | 94 | </ClCompile> |
95 | - <ClCompile Include="ChartDialog.cpp"> | ||
96 | - <Filter>Source Files</Filter> | ||
97 | - </ClCompile> | ||
98 | </ItemGroup> | 95 | </ItemGroup> |
99 | <ItemGroup> | 96 | <ItemGroup> |
100 | <CustomBuild Include="PaperGraphWidget.h"> | 97 | <CustomBuild Include="PaperGraphWidget.h"> |
... | @@ -132,8 +129,5 @@ | ... | @@ -132,8 +129,5 @@ |
132 | <ClInclude Include="json_processor.h"> | 129 | <ClInclude Include="json_processor.h"> |
133 | <Filter>Header Files</Filter> | 130 | <Filter>Header Files</Filter> |
134 | </ClInclude> | 131 | </ClInclude> |
135 | - <ClInclude Include="ChartDialog.h"> | ||
136 | - <Filter>Header Files</Filter> | ||
137 | - </ClInclude> | ||
138 | </ItemGroup> | 132 | </ItemGroup> |
139 | </Project> | 133 | </Project> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -80,6 +80,11 @@ void PaperGraphWidget::topk_with_pagerank() { | ... | @@ -80,6 +80,11 @@ void PaperGraphWidget::topk_with_pagerank() { |
80 | scene->update(); | 80 | scene->update(); |
81 | } | 81 | } |
82 | 82 | ||
83 | +void PaperGraphWidget::category_visualize() { | ||
84 | + graphItem->category_visualize(); | ||
85 | + scene->update(); | ||
86 | +} | ||
87 | + | ||
83 | void PaperGraphWidget::reset_color() | 88 | void PaperGraphWidget::reset_color() |
84 | { | 89 | { |
85 | graphItem->reset_color(); | 90 | graphItem->reset_color(); | ... | ... |
... | @@ -20,6 +20,7 @@ public: | ... | @@ -20,6 +20,7 @@ public: |
20 | void topk_with_target(); | 20 | void topk_with_target(); |
21 | void find_shortest_path(); | 21 | void find_shortest_path(); |
22 | void topk_with_pagerank(); | 22 | void topk_with_pagerank(); |
23 | + void category_visualize(); | ||
23 | void reset_color(); | 24 | void reset_color(); |
24 | 25 | ||
25 | //test | 26 | //test | ... | ... |
... | @@ -196,6 +196,60 @@ namespace { | ... | @@ -196,6 +196,60 @@ namespace { |
196 | 196 | ||
197 | /* json processor */ | 197 | /* json processor */ |
198 | json_processor _json_processor; | 198 | json_processor _json_processor; |
199 | + | ||
200 | + /* category keywords */ | ||
201 | + vector<vector<string>> keywords{ | ||
202 | + { "LANGUAGE", "TRANSLATION", "TEXT", "PHRASE", "PARAGRAPH" }, | ||
203 | + { "COMPLEXITY", "EXPONENTIALLY", "FOURIER", "CASCADE", "NP-COMPLETE" }, | ||
204 | + { "ENGINEERING", "FINANCE", "STOCHASTIC", "BUSINESS", "DAMAGE" }, | ||
205 | + { "GEOMETRY", "COLLINEAR", "DISTANCE", "DIMENSION", "GEOMETRIC" }, | ||
206 | + { "GAME", "GAMES", "INTERFERENCE", "REVENUE", "AGGREGATIVE" }, | ||
207 | + { "VISION", "PATTERN", "RECOGNITION", "FEATURE", "FIXATION" }, | ||
208 | + { "SOCIETY", "MEDIA", "SOCIAL", "MOBILE", "EVENT" }, | ||
209 | + { "CRYPTOGRAPHY", "SECURITY", "CODE", "CRYPTOSYSTEM" }, | ||
210 | + { "GRAPH", "POLYNOMIAL" }, | ||
211 | + { "DATABASE", "DATA", "JOIN", "TRANSACTION" }, | ||
212 | + { "LIBRARY", "PREPRINT", "RESEARCH" }, | ||
213 | + { "DISCRETE", "COMBINATORIC" }, | ||
214 | + { "DISTRIBUTED", "PARALLEL", "CLUSTER", "CLOUD" }, | ||
215 | + { "NEUTRON", "QUANTUM" }, | ||
216 | + { "LANGUAGE", "AUTOMATA" }, | ||
217 | + { "LITERATURE" }, | ||
218 | + { "GAUSSIAN", "3D", "SHAPE", "GRAPHIC" }, | ||
219 | + { "HARDWARE", "CAMERA", "CACHE", "ENERGY", "HYBRID" }, | ||
220 | + { "PERSON", "INDOOR", "HUMAN" }, | ||
221 | + { "MINING", "MICROBLOG", "METADATA" }, | ||
222 | + { "UPLINK", "INFORMATION" }, | ||
223 | + { "LEARNING", "DEEP", "NEURAL", "GAN", "CNN", "RNN" }, | ||
224 | + { "LOGIC", "HEURISTIC" }, | ||
225 | + { "MATHE", "MATRIX", "LINEAR", "ALGEBRA" }, | ||
226 | + { "MULTI-AGENT", "AGENT", "COLLABORATIVE", "CONVERGENCE" }, | ||
227 | + { "CODEC", "MEDIA", "AUDIO", "IMAGE" }, | ||
228 | + { "NETWORK", "INTERNET", "CLOUD", "SDN" }, | ||
229 | + { "NEURAL", "EVOLUTION", "LEARNING" }, | ||
230 | + { "NUMERICALLY", "NUMERICAL" }, | ||
231 | + { "SCHEDULING", "PREFETCHING", "VM", "SYSTEM", "LINUX" }, | ||
232 | + {}, | ||
233 | + { "PERFORMANCE", "HIGH", "ADAPTIVE" }, | ||
234 | + { "GRAMMAR", "PROGRAM" }, | ||
235 | + { "ROBOT", "ROBOTIC", "HARVESTER", "CRAWLER" }, | ||
236 | + { "SOCIAL", "INFORMATION", "LOCATION", "EVENT", "MICROBLOG" }, | ||
237 | + { "SOFTWARE", "ENGINEERING", "PROTOTYPE", "DEVELOPMENT" }, | ||
238 | + { "MULTI-CHANNEL", "ACOUSTIC", "AUDIO", "AUTOENCODER" }, | ||
239 | + { "SYMBOLIC", "FUNCTION", "COEFFICIENT" }, | ||
240 | + { "SYSTEM", "SENSORY", "TRANSFORMER", "CONTROL" } | ||
241 | + }; | ||
242 | + | ||
243 | + vector<string> category_colors{ | ||
244 | + "#694842","#325eee","#38cff1","#0b7d18","#20a920", | ||
245 | + "#ce112f","#479c12","#7cb382","#c4d5cb","#d52840", | ||
246 | + "#b6070e","#f1c50b","#181ce4","#6ed976","#abecdc", | ||
247 | + "#ddb390","#298d3e","#e48b31","#183083","#a03350", | ||
248 | + "#309c0c","#75fa48","#6ce15c","#82dee1","#845576", | ||
249 | + "#b9c3fb","#e59908","#30827a","#0658d1","#8b921c", | ||
250 | + "#fa7529","#b91ad2","#545e87","#cb6eae","#c2d4ba", | ||
251 | + "#dffa88","#5942d5","#32add6","#99443f","#c85b70" | ||
252 | + }; | ||
199 | } | 253 | } |
200 | 254 | ||
201 | /* boost */ | 255 | /* boost */ | ... | ... |
-
Please register or login to post a comment