Skip to content
Snippets Groups Projects

Main

Merged Große, Judith requested to merge bav1758/ci-s-projekt-verarbeitung:main into main
3 files
+ 243
0
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 101
0
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 3 16:54:43 2021
@author: Malte Schokolowski
"""
from bs4 import BeautifulSoup as bs
import requests as req
import sys
from pathlib import Path
import input_test as inp
def process_main(array, depth):
#ERROR-Handling doi_array = NULL, Tiefe < 0 oder 1 ??? +
if (depth < 0):
print("Error, depth of search must be positive")
# leeres Array für die Knoten wird erstellt
# leeres Array für die Kanten wird erstellt
global V, E
V = []
E = []
# Füge in Knoten-Array alle Starterknoten ein
for pub_doi in array:
pub = inp.input(pub_doi)
V.append(pub)
#print("\n")
process_rec(array, 0, depth)
return(V,E)
def process_rec(array, depth, depth_max):
depth += 1
for pub_doi in array:
# Input aufrufen und speichern
pub = inp.input(pub_doi)
# Klasseninstanz bestehend aus u.a.
# Name, Autoren, DOI, Jahr,
# was_wir_zitiert_haben, wo_wir_zitiert_wurden
for citation in pub._citations:
#print(pub.doi_url, ".\t", citation.doi_url, "\n")
#Knoten j erstellen, wenn noch unbekannt
if (citation not in V):
if (depth <= depth_max):
V.append(citation)
#print(citation.doi_url, "\n")
E.append([pub,citation])
#print(pub.doi_url, ".\t", citation.doi_url, "\n")
else:
E.append([pub,citation]) # Kante erstellen, wenn citation bekannt, also wenn beide im Input sind oder bei Zyklus
#print(pub.doi_url, ".\t", citation.doi_url, "\n")
#for k in wo_wir_zitiert_wurden:
#if (i != k):
#Knoten k erstellen, wenn noch unbekannt
#Kante erstellen von k nach i
if (depth < depth_max):
cit_arr = []
for citation in pub._citations:
if ("acs" in citation.doi_url):
cit_arr.append(citation.doi_url)
process_rec(cit_arr, depth, depth_max)
# Knoten- und Kantenmenge zurückgeben
# {1,2,3,4,5} oder
# {{1="paper1",0}, {2 = "paper2"},1} oder
# {1="paper1", 2 = "paper2"}
# {(1,2),(2,3),(2,4)}
arr = []
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/acs.accounts.1c00440')
#arr.append('https://doi.org/10.1021/ci700007b')
#arr.append('https://doi.org/10.1021/acs.jcim.5b00292')
#url = sys.argv[1]
#arr.append[url]
V,E = process_main(arr,1)
for vortex in V:
#print(vortex, "\n")
print(vortex.doi_url, "\n")
print("\n")
for i in range(len(E)):
#print(edge,"\n")
print(E[i][0].doi_url, ", ",E[i][1].doi_url, "\n")
\ No newline at end of file
Loading