(content_file, node_map, total_label, fea_len, train_num)
| 57 | return out_label |
| 58 | |
| 59 | def gen_node(content_file, node_map, total_label, fea_len, train_num): |
| 60 | label_map = {} |
| 61 | label_cnt = 0 |
| 62 | node_ids = [] |
| 63 | type = [] |
| 64 | label = [] |
| 65 | feature = [] |
| 66 | with open(os.path.realpath(content_file), 'r') as f: |
| 67 | for line in f: |
| 68 | features = line.strip().split('\t') |
| 69 | if len(features) != fea_len: |
| 70 | continue |
| 71 | node_ids.append(node_map[features[0]]) |
| 72 | feature.append(np.asarray(features[1:-1], dtype=int)) |
| 73 | if (node_map[features[0]]) > train_num: |
| 74 | type.append("test") |
| 75 | else: |
| 76 | type.append("train") |
| 77 | if not label_map.has_key(features[-1]): |
| 78 | label_map[features[-1]] = label_cnt |
| 79 | label_cnt += 1 |
| 80 | label.append(int2onehot(label_map[features[-1]], total_label)) |
| 81 | return node_ids, type, label, feature |
| 82 | |
| 83 | def parse_graph_file(file_dir, total_label, graph_name, fea_len, train_num): |
| 84 | content_file = os.path.join(file_dir, graph_name + ".content") |
no test coverage detected