Skip to content
Snippets Groups Projects
Commit b3e24faf authored by Victor Zimmermann's avatar Victor Zimmermann
Browse files

More graph saving.

parent 733e32e1
No related branches found
No related tags found
No related merge requests found
...@@ -347,8 +347,34 @@ def induce(topic_name: str, result_list: list) -> (nx.Graph, list, dict): ...@@ -347,8 +347,34 @@ def induce(topic_name: str, result_list: list) -> (nx.Graph, list, dict):
stat_dict['target'] = topic_name stat_dict['target'] = topic_name
print('[a]', 'Counting nodes and edges.\t('+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 #builds graph from these dictionaries, also applies multiple filters
print('[a]', 'Building graph.\t('+topic_name+')') print('[a]', 'Building graph.\t('+topic_name+')')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment