Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CiS Projekt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ockenden, Samuel
CiS Projekt
Commits
38b99391
Commit
38b99391
authored
3 years ago
by
Malte Schokolowski
Browse files
Options
Downloads
Patches
Plain Diff
removed Processing_test_doi_ueberarbeitet.py
parent
5b246d2c
No related branches found
Branches containing commit
No related tags found
2 merge requests
!7
Main
,
!5
Main
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
verarbeitung/Processing_test_doi_ueberarbeitet.py
+0
-117
0 additions, 117 deletions
verarbeitung/Processing_test_doi_ueberarbeitet.py
with
0 additions
and
117 deletions
verarbeitung/Processing_test_doi_ueberarbeitet.py
deleted
100644 → 0
+
0
−
117
View file @
5b246d2c
# -*- 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
from
input_fj
import
input
from
json_demo
import
output_to_json
def
process_main
(
doi_input_array
,
depth
):
# ERROR-Handling doi_array = NULL
if
(
len
(
doi_input_array
)
==
0
):
print
(
"
Error, no input data
"
)
# ERROR- wenn für die Tiefe eine negative Zahl eingegeben wird
if
(
depth
<
0
):
print
(
"
Error, depth of search must be positive
"
)
# Leeres Array für die Knoten(nodes) wird erstellt.
# Leeres Array für die Kanten(edges) wird erstellt.
global
nodes
,
edges
nodes
=
[]
edges
=
[]
# Jede Publikation aus dem Input-Array wird in den Knoten-Array(nodes) eingefügt.
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
:
doi_input_array
.
remove
(
pub_doi
)
process_rec_depth
(
doi_input_array
,
0
,
depth
)
output_to_json
(
nodes
,
edges
)
return
(
nodes
,
edges
)
def
process_rec_depth
(
array
,
depth
,
depth_max
):
# Die Tiefe wird bei jedem rekursiven Aufruf um 1 erhöht.
depth
+=
1
# Für jede Publikation im Input-Array wird ein Klassenobjekt erstellt.
for
pub_doi
in
array
:
pub
=
input
(
pub_doi
)
# Für jede citation, die in der entsprecheneden Klasseninstanz der Publikation gespeichert sind,
# wird geprüft, ob diese bereits als Knoten existiert.
for
citation
in
pub
.
_citations
:
# 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.
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
)
edges
.
append
([
pub
.
doi_url
,
citation
.
doi_url
])
# Wenn die citaion bereits im Knoten-Array existiert, wird nur die Verbindung zur Publikation
# als Tupel im Kanten-Array(edges) gespeichert.
else
:
edges
.
append
([
pub
.
doi_url
,
citation
.
doi_url
])
# Wenn die maximale Tiefe noch nicht erreicht wurde, werden alle citations aus der Publikation
# in ein Array geschrieben und mit diesem die Funktion erneut aufgerufen.
if
(
depth
<
depth_max
):
cit_arr
=
[]
for
citation
in
pub
.
_citations
:
# Momentan werden nur die citations mit acs in der URL gespeichert, da wir von anderen
# Quellen die Infotmationen nicht extrahieren können.
if
(
"
acs
"
in
citation
.
doi_url
):
cit_arr
.
append
(
citation
.
doi_url
)
# Rekusriver Aufruf der Funktion.
process_rec_depth
(
cit_arr
,
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://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]
nodes
,
edges
=
process_main
(
arr
,
1
)
print
(
"
Knoten:
\n
"
)
for
node
in
nodes
:
print
(
node
.
title
,
"
\n
"
)
print
(
"
\n
Kanten:
\n
"
)
for
edge
in
edges
:
print
(
edge
,
"
\n
"
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment