Skip to content

Commit

Permalink
changed json processing to file
Browse files Browse the repository at this point in the history
  • Loading branch information
bernd-mueller committed Jul 9, 2024
1 parent c963d27 commit b44c60a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
54 changes: 25 additions & 29 deletions .github/workflows/process_profile_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
schema = Namespace("http://schema.org/")

# Function to generate RDF for a specified profile using triples according to the Profile Ontology.
def generate_rdf_for_profile(profile_name, label, comment, publisher, is_profile_of, webpage_url, jsonld_urls, outputfilename, filetype):
def generate_rdf_for_profile(profile_name, label, comment, publisher, is_profile_of, webpage_url, f, outputfilename, filetype):
# Loading JSON-LD from repository as graph using rdflib
g = Graph()
g.parse(jsonld_urls, format="application/ld+json")
g.parse(file=f, format="application/ld+json")

# Creating profile URI
profile_uri = URIRef(str(bioschemas) + profile_name.capitalize() + "/")
Expand Down Expand Up @@ -54,37 +54,33 @@ def generate_rdf_for_profile(profile_name, label, comment, publisher, is_profile
# is taken to generate enriched turtle files.
def processProfiles (filename, profilename):
# Retrieving all released json files from BioSchemas github repository

with open(filename) as f:
print("Loading file as json ", filename)
toProc = json.load(f)
profiles = []
profilenames = []
weburls = []
downloadurls = []
profilelatestversions = []
profiles = []
profilenames = []
weburls = []
downloadurls = []
profilelatestversions = []

# browsable url of the repository
weburl = "https://github.com/BioSchemas/specifications/blob/master/"
# browsable url of the repository
weburl = "https://github.com/BioSchemas/specifications/blob/master/"

# url to download the raw json file
downloadurl = "https://raw.githubusercontent.com/BioSchemas/specifications/master/"
# url to download the raw json file
downloadurl = "https://raw.githubusercontent.com/BioSchemas/specifications/master/"

print("Processing " + profilename)
webpage_url = weburl+profilename
download_url = downloadurl+profilename
print("Processing " + profilename)
webpage_url = weburl+profilename
download_url = downloadurl+profilename

# generating additional profile triples to store with retrieved JSON-LD
generate_rdf_for_profile(
profile_name=profilename,
label=f"{profilename.capitalize()} Profile",
comment="",
publisher=webpage_url,
is_profile_of=profilename.capitalize(),
webpage_url=webpage_url,
jsonld_urls=toProc,
outputfilename=profilename,
filetype="ttl")
# generating additional profile triples to store with retrieved JSON-LD
generate_rdf_for_profile(
profile_name=profilename,
label=f"{profilename.capitalize()} Profile",
comment="",
publisher=webpage_url,
is_profile_of=profilename.capitalize(),
webpage_url=webpage_url,
jsonld_urls=filename,
outputfilename=profilename,
filetype="ttl")


# ## Main Script
Expand Down
2 changes: 1 addition & 1 deletion ChemicalSubstance/jsonld/ChemicalSubstance_v0.5-DRAFT.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"@context": {
"schema": "http://schema.org/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
Expand Down

0 comments on commit b44c60a

Please sign in to comment.