Commit 5e6a4953 authored by Victor Zimmermann's avatar Victor Zimmermann
Browse files

Formatting.

parent 9af20889
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ def induce(topic_name: str, result_list: list) -> (nx.Graph, list, dict):
                node_freq_dict = json.load(node_file)
                edge_freq_dict = json.load(edge_file)

                edge_freq_dict = {(key1,key2):value2 for key1,value1 in edge_freq_dict.items() for key2,value2 in value1.items()}

            continue
    
    if graph_in_existence == False:
@@ -157,6 +159,15 @@ def induce(topic_name: str, result_list: list) -> (nx.Graph, list, dict):
        with open(config.graph+node_dict_name, 'w') as node_file, open(config.graph+edge_dict_name, 'w') as edge_file:
            
            json.dump(node_freq_dict, node_file)

            new_dict = dict()
            for key,value in edge_freq_dict.items():
                if key[0] in new_dict:
                    key[0].add({key[1]:value})
                else:
                    key[0] = {key[1]:value}

            edge_freq_dict = new_dict
            json.dump(edge_freq_dict, edge_file)

    #builds graph from these dictionaries, also applies multiple filters
+11 −0
Original line number Diff line number Diff line
@@ -366,6 +366,8 @@ def induce(topic_name: str, result_list: list) -> (nx.Graph, list, dict):
                node_freq_dict = json.load(node_file)
                edge_freq_dict = json.load(edge_file)

                edge_freq_dict = {(key1,key2):value2 for key1,value1 in edge_freq_dict.items() for key2,value2 in value1.items()}

            continue
    
    if graph_in_existence == False:
@@ -375,6 +377,15 @@ def induce(topic_name: str, result_list: list) -> (nx.Graph, list, dict):
        with open(config.graph+node_dict_name, 'w') as node_file, open(config.graph+edge_dict_name, 'w') as edge_file:
            
            json.dump(node_freq_dict, node_file)
            
            new_dict = dict()
            for key,value in edge_freq_dict.items():
                if key[0] in new_dict:
                    key[0].add({key[1]:value})
                else:
                    key[0] = {key[1]:value}

            edge_freq_dict = new_dict
            json.dump(edge_freq_dict, edge_file)
    
    #builds graph from these dictionaries, also applies multiple filters