def get_prop_sim_matrix(graph, graph1): centra = Centrality() aifsim = Aifsim() g_copy = graph.copy() g1_copy = graph1.copy() g_inodes = centra.get_i_node_list(g_copy) g1_inodes = centra.get_i_node_list(g1_copy) relsi, valsi, switched = aifsim.text_sim_matrix(g_inodes, g1_inodes) #if switched the relations have been switched order so they need reversed when creating the dictionary rels_dict = aifsim.rels_to_dict(relsi, switched) return rels_dict
def get_graph_sim(aif_id1, aif_id2): centra = Centrality() aifsim = Aifsim() graph, json = aifsim.get_graph(aif_id1, centra) graph1, json1 = aifsim.get_graph(aif_id2, centra) graph = centra.remove_iso_analyst_nodes(graph) graph1 = centra.remove_iso_analyst_nodes(graph1) rep_form = aifsim.is_iat(graph, graph1, centra) g_copy = graph.copy() g1_copy = graph1.copy() graph_mean = 0 text_mean = 0 overall_mean = 0 if rep_form == 'diff': return 'Error' else: graph_mean = aifsim.call_diagram_parts_and_sum( g_copy, g1_copy, rep_form) if rep_form == 'aif': g_inodes = centra.get_i_node_list(g_copy) g1_inodes = centra.get_i_node_list(g1_copy) relsi, valsi, switched = aifsim.text_sim_matrix( g_inodes, g1_inodes) i_mean = aifsim.get_mean_of_list(valsi) text_mean = i_mean else: g_inodes = centra.get_i_node_list(g_copy) g1_inodes = centra.get_i_node_list(g1_copy) g_lnodes = centra.get_l_node_list(g_copy) g1_lnodes = centra.get_l_node_list(g1_copy) relsi, valsi, switched = aifsim.text_sim_matrix( g_inodes, g1_inodes) relsl, valsl, switched = aifsim.text_sim_matrix( g_lnodes, g1_lnodes) i_mean = aifsim.get_mean_of_list(valsi) l_mean = aifsim.get_mean_of_list(valsl) text_mean = aifsim.get_l_i_mean(l_mean, i_mean) overall_score = aifsim.get_l_i_mean(text_mean, graph_mean) return overall_score, text_mean, graph_mean