From 5e9a113be39ba672bd7f06684def7501f3c5d33b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernd=20M=C3=BCller?= Date: Tue, 5 Nov 2024 13:05:18 +0100 Subject: [PATCH] providing static context definition as parameter for graph serialization --- .github/workflows/process_profile_script.py | 33 ++++----------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/.github/workflows/process_profile_script.py b/.github/workflows/process_profile_script.py index 10ed3e9..f21eab5 100644 --- a/.github/workflows/process_profile_script.py +++ b/.github/workflows/process_profile_script.py @@ -53,36 +53,15 @@ def generate_rdf_for_profile(self, profile_name, label, comment, publisher, is_p # save the graph with additional profile triples # outfile = outputfilename+"."+filetype + context = { + "schema": "http://schema.org/", + "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "bioschemas": "https://discovery.biothings.io/view/bioschemas/"} outfile = outputfilename - g.serialize(destination=outfile, format="json-ld", auto_compact=True) + g.serialize(destination=outfile, format="json-ld", context=context) print("Writing result to", outfile) g.close() - # postproc = """ - # { - # "@context": { - # "schema": "http://schema.org/", - # "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", - # "rdfs": "http://www.w3.org/2000/01/rdf-schema#", - # "bioschemas": "https://discovery.biothings.io/view/bioschemas/" - # }, - # "@graph": - # """ - - # print("Postprocessing file to legit Bioschemas file format.") - - # enriched = "" - # with open(outfile, 'r') as file: - # for line in file: - # enriched += line.strip() + "\n" - # file.close() - - # postproc = postproc + enriched + "\n}" - - # with open(outfile, "w") as file: - # file.write(postproc) - # file.close() - - # Process profile information from the GitHub repository of BioSchemas. All profiles in JSON-LD format