summaryrefslogtreecommitdiff
path: root/schema/to-jsonld.py
diff options
context:
space:
mode:
Diffstat (limited to 'schema/to-jsonld.py')
-rw-r--r--schema/to-jsonld.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/schema/to-jsonld.py b/schema/to-jsonld.py
new file mode 100644
index 00000000..e48607fd
--- /dev/null
+++ b/schema/to-jsonld.py
@@ -0,0 +1,21 @@
+# Convert all definitions to JSON-LD.
+
+# Requires RDFLib and SuRF.
+
+import surf
+
+import parse
+
+
+all_data = parse.load_all_morphologies(path='..')
+
+def serialize_to_json_ld(rdflib_graph):
+ context = {
+ "@vocab": "http://baserock.org/definitions/example-schema#",
+ "@language": "en"
+ }
+ # requires rdflib-jsonld Python module.
+ return rdflib_graph.serialize(format='json-ld', indent=4, context=context)
+
+with open('definitions.json-ld', 'w') as f:
+ f.write(serialize_to_json_ld(all_data))