diff --git a/verarbeitung/test/Processing_unittest.py b/verarbeitung/test/Processing_unittest.py index 47dd268885d14a254ced584c24d5a9e4dcafb0e8..b17f5e4f6768722c9c9d35bacbb5226cafd156d2 100644 --- a/verarbeitung/test/Processing_unittest.py +++ b/verarbeitung/test/Processing_unittest.py @@ -94,7 +94,7 @@ class ProcessingTest(unittest.TestCase): nodes_old_single, edges_old_single = process_main(['doi_lg_1_i'],2,2,True) nodes_old_both, edges_old_both = process_main(['doi_lg_1_i','doi_lg_2_i'],2,2,True) nodes_new_both, edges_new_both = input_from_json('test_output.json') - nodes_new_single, edges_new_single = check_graph_updates(['doi_lg_1_i'], nodes_old_both, edges_old_both, True) + nodes_new_single, edges_new_single = check_graph_updates(['doi_lg_1_i'], nodes_old_both, edges_old_both, 'test_output.json', 2, 2, True) self.assertCountEqual(nodes_old_single,nodes_new_single) self.assertCountEqual(edges_old_single, edges_new_single) diff --git a/verarbeitung/update_graph/connect_new_input.py b/verarbeitung/update_graph/connect_new_input.py index 6a910c1199eba0daba4dbee00d4c248d5a278891..4f6b91f0e149d5dad5484c815cc4b2a48088f4bc 100644 --- a/verarbeitung/update_graph/connect_new_input.py +++ b/verarbeitung/update_graph/connect_new_input.py @@ -23,14 +23,14 @@ from verarbeitung.construct_new_graph.Processing import initialize_nodes_list, c from verarbeitung.construct_new_graph.add_citations_rec import add_citations from verarbeitung.construct_new_graph.export_to_json import output_to_json -def connect_old_and_new_input(json_file, new_doi_list, search_height, search_depth, test_var = False): +def connect_old_and_new_input(json_file, new_doi_list, search_depth, search_height, test_var = False): global nodes, edges nodes = [] edges = [] nodes, edges = input_from_json(json_file) - complete_changed_group_nodes(new_doi_list, search_height, search_depth, test_var) + complete_changed_group_nodes(new_doi_list, search_depth, search_height, test_var) # initializes nodes/edges from input and gets a list with publication objects for citations and references returned references_obj_list, citations_obj_list = initialize_nodes_list(new_doi_list,search_depth, search_height, test_var) @@ -48,21 +48,17 @@ def connect_old_and_new_input(json_file, new_doi_list, search_height, search_dep return(nodes, edges) -def complete_changed_group_nodes(new_doi_list, search_height_max, search_depth_max, test_var): +def complete_changed_group_nodes(new_doi_list, search_depth_max, search_height_max, test_var): changed_group_node_citations = [] changed_group_node_references = [] for node in nodes: - if (node.group != 0) and (node.doi in new_doi_list): - node.group = 0 - - # inserts references as publication objects into list and - # inserts first depth references into nodes/edges if maximum search depth > 0 - for reference in add_citations(nodes, edges, node, 0, search_depth_max, "Reference", test_var): - changed_group_node_references.append(reference) - - # inserts citations as publication objects into list and - # inserts first height citations into nodes if maximum search height > 0 - for citation in add_citations(nodes, edges, node, 0, search_height_max, "Citation", test_var): - changed_group_node_citations.append(citation) + if (node.group < 0) and (node.doi in new_doi_list): + node.group = "input" + + + + elif (node.group > 0): + node.group = "input" + diff --git a/verarbeitung/update_graph/update_graph.py b/verarbeitung/update_graph/update_graph.py index 787a7d351c0e849d4a43d96964b4d2f09ee822d9..0571cd096cf5b31146769dcdce713644d4b24a62 100644 --- a/verarbeitung/update_graph/update_graph.py +++ b/verarbeitung/update_graph/update_graph.py @@ -23,6 +23,7 @@ from input.publication import Publication from verarbeitung.get_pub_from_input import get_pub from .Knoten_Vergleich import doi_listen_vergleichen from .update_graph_del import delete_nodes_and_edges +from .connect_new_input import connect_old_and_new_input def get_old_input_dois(old_obj_input_list): @@ -64,7 +65,7 @@ def get_new_input_dois(new_input, test_var): return(new_input_dois) -def check_graph_updates(new_doi_input_list, old_obj_input_list, old_edges_list, test_var = False): +def check_graph_updates(new_doi_input_list, old_obj_input_list, old_edges_list, json_file, search_depth, search_height, test_var = False): ''' :param new_doi_input_list: input list of doi from UI :type new_doi_input_list: list of strings @@ -101,5 +102,7 @@ def check_graph_updates(new_doi_input_list, old_obj_input_list, old_edges_list, if (len(deleted_nodes) > 0): processed_input_list_del, valid_edges_del = delete_nodes_and_edges(processed_input_list, deleted_nodes, old_doi_input_list, old_edges_list) + if (len(inserted_nodes) > 0): + connect_old_and_new_input(json_file, inserted_nodes, search_depth, search_height, test_var) return(processed_input_list_del, valid_edges_del)