# -*- coding: utf-8 -*- """ Functions to update a graph representing citations between multiple ACS/Nature journals """ __authors__ = "Donna Löding, Alina Molkentin, Xinyi Tang, Judith Große, Malte Schokolowski" __email__ = "cis-project2021@zbh.uni-hamburg.de" __status__ = "Production" #__copyright__ = "" #__credits__ = ["", "", "", ""] #__license__ = "" #__version__ = "" #__maintainer__ = "" import sys from pathlib import Path from os import error sys.path.append("../") from .import_from_json import input_from_json from verarbeitung.construct_new_graph.Processing import initialize_nodes_list, complete_inner_edges 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_depth, search_height, test_var = False): ''' :param json_file: json file with old graph :type json_file: json file :param new_doi_list: additional dois which has to be connected to the old graph :type new_doi_list: list of strings :param search_depth: depth to search for references :type search_depth: int :param search_height: height to search for citations :type search_height: int :param test_var: variable to differenciate between test and url call :type test_var: boolean connetcs the old graph and the new input dois to a complete new graph ''' global nodes, edges nodes = [] edges = [] nodes, edges = input_from_json(json_file) 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) # function calls to begin recursive processing up to max depth/height add_citations(nodes, edges, citations_obj_list, 1, search_height, "Citation", test_var) add_citations(nodes, edges, references_obj_list, 1, search_depth, "Reference", test_var) # adds edges between reference group and citation group of known publications complete_inner_edges(test_var) # calls a skript to save nodes and edges of graph in .json file output_to_json(nodes,edges, test_var) return(nodes, edges) def complete_changed_group_nodes(new_doi_list, search_depth_max, search_height_max, test_var): ''' work in progress ''' 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 = "input" elif (node.group > 0) and (node.doi in new_doi_list): node.group = "input"