Loading src/abstinent.py +27 −1 Original line number Diff line number Diff line Loading @@ -348,7 +348,33 @@ def induce(topic_name: str, result_list: list) -> (nx.Graph, list, dict): stat_dict['target'] = topic_name print('[a]', 'Counting nodes and edges.\t('+topic_name+')') node_freq_dict, edge_freq_dict = frequencies(topic_name, result_list) #Check if frequencies were already counted before. node_dict_name = topic_name+'_node.json' edge_dict_name = topic_name+'_edge.json' graph_in_existence = False for graph_name in os.listdir(config.graph): if topic_name in graph_name: graph_in_existence = True with open(config.graph+node_dict_name, 'r') as node_file, open(config.graph+edge_dict_name, 'r') as edge_file: node_freq_dict = json.load(node_file) edge_freq_dict = json.load(edge_file) continue if graph_in_existence == False: node_freq_dict, edge_freq_dict = frequencies(target_string, result_list) with open(config.graph+node_dict_name, 'w') as node_file, open(config.graph+edge_dict_name, 'w') as edge_file: node_file.write(json.dumps(node_freq_dict)) edge_file.write(json.dumps(edge_freq_dict)) #builds graph from these dictionaries, also applies multiple filters print('[a]', 'Building graph.\t('+topic_name+')') Loading Loading
src/abstinent.py +27 −1 Original line number Diff line number Diff line Loading @@ -348,7 +348,33 @@ def induce(topic_name: str, result_list: list) -> (nx.Graph, list, dict): stat_dict['target'] = topic_name print('[a]', 'Counting nodes and edges.\t('+topic_name+')') node_freq_dict, edge_freq_dict = frequencies(topic_name, result_list) #Check if frequencies were already counted before. node_dict_name = topic_name+'_node.json' edge_dict_name = topic_name+'_edge.json' graph_in_existence = False for graph_name in os.listdir(config.graph): if topic_name in graph_name: graph_in_existence = True with open(config.graph+node_dict_name, 'r') as node_file, open(config.graph+edge_dict_name, 'r') as edge_file: node_freq_dict = json.load(node_file) edge_freq_dict = json.load(edge_file) continue if graph_in_existence == False: node_freq_dict, edge_freq_dict = frequencies(target_string, result_list) with open(config.graph+node_dict_name, 'w') as node_file, open(config.graph+edge_dict_name, 'w') as edge_file: node_file.write(json.dumps(node_freq_dict)) edge_file.write(json.dumps(edge_freq_dict)) #builds graph from these dictionaries, also applies multiple filters print('[a]', 'Building graph.\t('+topic_name+')') Loading