Skip to content
Snippets Groups Projects

Main

Merged Große, Judith requested to merge bav1758/ci-s-projekt-verarbeitung:main into main
7 files
+ 25
400
Compare changes
  • Side-by-side
  • Inline

Files

@@ -10,12 +10,13 @@ import requests as req
import sys
from pathlib import Path
from input_fj import input
from json_demo import output_to_json
def process_main(array, depth):
def process_main(doi_input_array, depth):
# ERROR-Handling doi_array = NULL
if (len(array) == 0):
if (len(doi_input_array) == 0):
print("Error, no input data")
# ERROR- wenn für die Tiefe eine negative Zahl eingegeben wird
@@ -30,14 +31,21 @@ def process_main(array, depth):
edges = []
# Jede Publikation aus dem Input-Array wird in den Knoten-Array(nodes) eingefügt.
for pub in array:
if (pub not in nodes):
for pub_doi in doi_input_array:
pub = input(pub_doi)
not_in_nodes = True
for node in nodes:
if (pub.doi_url == node.doi_url):
not_in_nodes = False
break
if (not_in_nodes):
nodes.append(pub)
else:
array.remove(pub)
doi_input_array.remove(pub_doi)
process_rec_depth(array, 0, depth)
process_rec_depth(doi_input_array, 0, depth)
output_to_json(nodes,edges)
return(nodes,edges)
@@ -56,9 +64,14 @@ def process_rec_depth(array, depth, depth_max):
# Wenn die citation noch nicht im Knoten-Array(nodes) existiert UND die maximale Tiefe
# noch nicht erreicht wurde, wird diese als Knoten im Knoten-Array gespeichert. Zusätzlich
# wird die Verbindung zur Publikation als Tupel im Kanten-Array(edges) gespeichert.
if (citation.doi_url not in nodes):
not_in_nodes = True
for node in nodes:
if (citation.doi_url == node.doi_url):
not_in_nodes = False
break
if (not_in_nodes):
if (depth <= depth_max):
nodes.append(citation.doi_url)
nodes.append(citation)
edges.append([pub.doi_url,citation.doi_url])
# Wenn die citaion bereits im Knoten-Array existiert, wird nur die Verbindung zur Publikation
@@ -85,8 +98,8 @@ def process_rec_depth(array, depth, depth_max):
# Programmtest, weil noch keine Verbindung zum Input besteht.
arr = []
arr.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249')
#arr.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249')
#arr.append('https://doi.org/10.1021/acs.jmedchem.0c01332')
arr.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249')
arr.append('https://doi.org/10.1021/acs.jmedchem.0c01332')
#arr.append('https://doi.org/10.1021/acs.jcim.0c00741')
#arr.append('https://doi.org/10.1021/ci700007b')
@@ -97,8 +110,8 @@ arr.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249')
nodes,edges = process_main(arr,1)
print("Knoten:\n")
for vortex in nodes:
print(vortex, "\n")
for node in nodes:
print(node.title, "\n")
print("\nKanten:\n")
for edge in edges:
print(edge,"\n")
\ No newline at end of file
Loading