summaryrefslogtreecommitdiff
path: root/schema/to-jsonld.py
blob: e48607fd2628e5b2469b55c4ceb063a633e7986d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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))