Skip to content

Commit

Permalink
Add converter script to JSON-LD
Browse files Browse the repository at this point in the history
  • Loading branch information
tijmenbaarda committed Aug 14, 2024
1 parent 910805c commit b1e7424
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
pip install -r tests/requirements.txt
- name: Validate Turtle file
run: |
python -m pytest tests
python -m pytest utils
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions utils/to_jsonld.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from rdflib import Graph
from pathlib import Path

ONTOLOGY_FILE = Path(__file__).parent.parent / 'edpop-record-ontology.ttl'
JSONLD_FILE = ONTOLOGY_FILE.parent / (ONTOLOGY_FILE.name.removesuffix(".ttl") + ".json")


context = {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"owl": "http://www.w3.org/2002/07/owl#",
"dc": "http://purl.org/dc/elements/1.1/",
"dcterms": "http://purl.org/dc/terms/",
"skos": "http://www.w3.org/2004/02/skos/core#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"edpoprec": "https://dhstatic.hum.uu.nl/edpop-records/0.1.0-SNAPSHOT/",
}


g = Graph()
g.parse(ONTOLOGY_FILE)
g.serialize(format="json-ld", destination=JSONLD_FILE, context=context)

0 comments on commit b1e7424

Please sign in to comment.