diff --git a/verarbeitung/connect_new_input.py b/verarbeitung/connect_new_input.py new file mode 100644 index 0000000000000000000000000000000000000000..b9167dca95d8f2c7175c3820428d366a78468eaa --- /dev/null +++ b/verarbeitung/connect_new_input.py @@ -0,0 +1,67 @@ +# -*- 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_form_json import input_from_json +from Processing import initialize_nodes_list, process_citations_rec, process_references_rec, complete_inner_edges, create_graph_structure_references, create_graph_structure_citations +from json_demo import output_to_json + +def connect_old_and_new_input(json_file, new_doi_list, search_height, search_depth, 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) + + # 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 + process_citations_rec(citations_obj_list, 1, search_height, test_var) + process_references_rec(references_obj_list, 1, search_depth, 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_height_max, search_depth_max, test_var): + changed_group_node_citations = [] + changed_group_node_references = [] + + for node in nodes: + if (node.group != "input") and (node.doi in new_doi_list): + node.group = "input" + + # inserts references as publication objects into list and + # inserts first depth references into nodes/edges if maximum search depth > 0 + for reference in create_graph_structure_references(node, 0, search_depth_max, 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 create_graph_structure_citations(node, 0, search_height_max, test_var): + changed_group_node_citations.append(citation) +