From 2e58c1fc119d3a406e28847115634b8f766c0ef3 Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Fri, 22 Mar 2024 17:03:05 -0600 Subject: [PATCH] Implement Class NodeKind support Add support for Classes to specify what kind of node they must be (e.g. "IRI", "BlankNode", "BlankNodeOrIRI") --- spec_parser/model.py | 1 + spec_parser/rdf.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/spec_parser/model.py b/spec_parser/model.py index 9194d3d..dac5dd3 100644 --- a/spec_parser/model.py +++ b/spec_parser/model.py @@ -154,6 +154,7 @@ class Class: "Instantiability", "name", "SubclassOf", + "NodeKind", ) VALID_PROP_METADATA = ( "maxCount", diff --git a/spec_parser/rdf.py b/spec_parser/rdf.py index 15fe4fe..4f52b6f 100644 --- a/spec_parser/rdf.py +++ b/spec_parser/rdf.py @@ -68,6 +68,11 @@ def gen_rdf_ontology(model): pns = "" if parent.startswith("/") else f"/{c.ns.name}/" p = model.classes[pns+parent] g.add((node, RDFS.subClassOf, URIRef(p.iri))) + + node_kind = c.metadata.get("NodeKind") + if node_kind: + g.add((node, SH.nodeKind, getattr(SH, node_kind))) + for p in c.properties: fqprop = c.properties[p]["fqname"] if fqprop == "/Core/spdxId":