Skip to content
Snippets Groups Projects
Commit 81489864 authored by Malte Schokolowski's avatar Malte Schokolowski
Browse files

added Processing_test.py v1.0

parent 1915b423
No related branches found
No related tags found
2 merge requests!7Main,!5Main
# -*- 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
# -*- 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 in array:
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
#print(pub_doi)
pub = inp.input(pub_doi)
#for cit in pub._citations:
#print(pub.doi_url, cit.doi_url)
# 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.doi_url not in V):
if (depth <= depth_max):
V.append(citation.doi_url)
#print(citation.doi_url, "\n")
E.append([pub.doi_url,citation.doi_url])
#print(pub.doi_url, ".\t", citation.doi_url, "\n")
else:
E.append([pub.doi_url,citation.doi_url]) # Kante erstellen, wenn citation bekannt, also wenn beide in gleicher Tiefe 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)
#else:
#print("--- %s seconds ---" % (time.time() - start_time))
#process_rec(wo_wir_zitiert_wurden, depth -1)'''
# 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/ci700007b')
#arr.append('https://doi.org/10.1021/acs.jcim.5b00292')
#url = sys.argv[1]
#arr.append[url]
V,E = process_main(arr,2)
for vortex in V:
print(vortex, "\n")
print("\n")
for edge in E:
print(edge,"\n")
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
@author: Malte Schokolowski
"""
def process_main(doi_array, depth):
#ERROR-Handling doi_array = NULL, Tiefe < 0 oder 1 ???
# leeres Array für die Knoten wird erstellt
# leeres Array für die Kanten wird erstellt
# Füge in Knoten-Array alle Starterknoten ein
process_rec(doi_array, depth)
def process_rec(doi_array, depth):
for i in range(len(doi_array)):
# Input aufrufen und speichern
# Klasseninstanz bestehend aus u.a.
# Name, Autoren, DOI, Jahr,
# was_wir_zitiert_haben, wo_wir_zitiert_wurden
for j in range(len(was_wir_zitiert_haben)):
#Knoten j erstellen, wenn noch unbekannt
#Kante erstellen von i nach j
for k in range(len(wo_wir_zitiert_wurden)):
if (i != k):
#Knoten k erstellen, wenn noch unbekannt
#Kante erstellen von k nach i
process_rec(was_wir_zitiert_haben, depth-1)
process_rec(wo_wir_zitiert_wurden, depth -1)
# 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)}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment