def show_similarity(gid_x, gid_y): """ """ novel_node_x = show_cluster_node(gid_x) novel_node_y = show_cluster_node(gid_y) cluster_similarity = NovelSimilarityModule() similarity, match_list = cluster_similarity.novel_node_similarity_calculation(novel_node_x, novel_node_y) print(similarity) print(match_list)
for table_id in xrange(1, 256): sql = 'SELECT dir_id FROM novel_cluster_dir_info{0} WHERE book_name = "{1}"'.format(table_id, novel_node.book_name.encode('GBK')) cursor = conn.cursor() cursor.execute(sql) for (id, ) in cursor.fetchall(): id_list.append(id) cursor.close() if len(id_list) == 0: continue print_novel_node(novel_node, dir_id) similarity = NovelSimilarityModule() for id in id_list: node = get_novel_node(conn, id) print_novel_node(node, id) print(similarity.novel_node_similarity_calculation(novel_node, node)) novel_node = node conn.close() here()