From c65e78dca23d6428d4024ac9b4c92f52b2a107d3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Sep 2025 14:50:12 +0000 Subject: [PATCH 1/3] Initial plan From 02874d583ce63601280315513352f301dba08bc8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Sep 2025 15:02:00 +0000 Subject: [PATCH 2/3] Implement SHACL property shapes support in incoming/outgoing class JSON views Co-authored-by: jpmccu <602385+jpmccu@users.noreply.github.com> --- whyis/namespace.py | 1 + whyis/templates/incoming_class.json | 20 ++++++++++++++++++++ whyis/templates/outgoing_class.json | 26 ++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/whyis/namespace.py b/whyis/namespace.py index 38dda9dda..19f1f3f49 100644 --- a/whyis/namespace.py +++ b/whyis/namespace.py @@ -51,6 +51,7 @@ class NamespaceContainer(object): sdd = rdflib.Namespace("http://purl.org/twc/sdd/") csvw = rdflib.Namespace("http://www.w3.org/ns/csvw#") text = rdflib.Namespace("http://jena.apache.org/fulltext#") + sh = rdflib.Namespace("http://www.w3.org/ns/shacl#") @property def prefixes(self): diff --git a/whyis/templates/incoming_class.json b/whyis/templates/incoming_class.json index 229927077..8cbc29a93 100644 --- a/whyis/templates/incoming_class.json +++ b/whyis/templates/incoming_class.json @@ -1,8 +1,28 @@ {{'''graph ?assertion { { + # Original class hierarchy relationships ?source rdfs:subClassOf|owl:equivalentClass ?target. ?source ?link_type ?target. } + UNION { + # SHACL property shapes linking classes: NodeShape -> targetClass + ?source sh:targetClass ?target. + ?source ?link_type ?target. + } + UNION { + # SHACL property shapes: PropertyShape with sh:class/sh:node pointing to target + ?nodeshape sh:property ?source. + ?source sh:class|sh:node ?target. + ?source ?link_type ?target. + } + UNION { + # Classes used directly as NodeShapes with property shapes + ?source rdf:type sh:NodeShape. + ?source sh:property ?propshape. + ?propshape sh:class|sh:node ?target. + ?propshape ?link_type ?target. + bind(?source as ?source) + } } bind(1 as ?probability) bind(?assertion as ?link) diff --git a/whyis/templates/outgoing_class.json b/whyis/templates/outgoing_class.json index 9f5df2e70..cce8bab7d 100644 --- a/whyis/templates/outgoing_class.json +++ b/whyis/templates/outgoing_class.json @@ -1,8 +1,34 @@ {{'''graph ?assertion { { + # Original class hierarchy relationships ?source rdfs:subClassOf ?target. ?source ?link_type ?target. } + UNION { + # SHACL NodeShape: current class targets other classes + ?source sh:targetClass ?target. + ?source ?link_type ?target. + } + UNION { + # SHACL PropertyShape: current class has property shapes pointing to other classes + ?source sh:property ?propshape. + ?propshape sh:class|sh:node ?target. + ?propshape ?link_type ?target. + } + UNION { + # Current class used as NodeShape with property shapes pointing to other classes + ?source rdf:type sh:NodeShape. + ?source sh:property ?propshape. + ?propshape sh:class|sh:node ?target. + ?propshape ?link_type ?target. + } + UNION { + # Property shapes where current class is referenced via sh:class/sh:node + ?nodeshape sh:property ?propshape. + ?propshape sh:class|sh:node ?source. + ?nodeshape sh:targetClass ?target. + ?nodeshape ?link_type ?target. + } } bind(1 as ?probability) bind(?assertion as ?link) From 97eeb86edd1e6782e5144cc4bd8007b730a2dfa5 Mon Sep 17 00:00:00 2001 From: Jamie McCusker Date: Thu, 11 Sep 2025 11:09:16 -0400 Subject: [PATCH 3/3] Clean up SHACL property shapes in incoming_class.json --- whyis/templates/incoming_class.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/whyis/templates/incoming_class.json b/whyis/templates/incoming_class.json index 8cbc29a93..7da7f6c0f 100644 --- a/whyis/templates/incoming_class.json +++ b/whyis/templates/incoming_class.json @@ -4,11 +4,6 @@ ?source rdfs:subClassOf|owl:equivalentClass ?target. ?source ?link_type ?target. } - UNION { - # SHACL property shapes linking classes: NodeShape -> targetClass - ?source sh:targetClass ?target. - ?source ?link_type ?target. - } UNION { # SHACL property shapes: PropertyShape with sh:class/sh:node pointing to target ?nodeshape sh:property ?source.