Skip to content

Commit 4efc4ac

Browse files
Also count node shapes for the execution report
1 parent 1cd1bb9 commit 4efc4ac

File tree

4 files changed

+97
-85
lines changed

4 files changed

+97
-85
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/)
66

7+
## [Unreleased]
8+
9+
### Changed
10+
11+
- Also count node shapes for the execution report
712

813
## [2.0.0] 2025-02-10
914

cmem_plugin_shapes/plugin_shapes.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def format_prefixes(prefixes: dict, formatted_prefixes: dict | None = None) -> d
160160
formatted_prefixes = {}
161161
for prefix, namespace in prefixes.items():
162162
formatted_prefixes.setdefault(namespace, []).append(prefix + ":")
163+
163164
return formatted_prefixes
164165

165166
def get_prefixes(self) -> dict:
@@ -180,7 +181,6 @@ def get_prefixes(self) -> dict:
180181
if not prefixes_cc or not self.prefix_cc:
181182
with (Path(__path__[0]) / "prefix_cc.json").open("r", encoding="utf-8") as json_file:
182183
prefixes_cc = json.load(json_file)
183-
184184
if prefixes_cc:
185185
prefixes = self.format_prefixes(prefixes_cc, prefixes)
186186

@@ -214,13 +214,11 @@ def get_name(self, iri: str) -> str:
214214
except IndexError as exc:
215215
raise IndexError(f"{title_json['title']} {prefixes}") from exc
216216
title += f" ({prefix})"
217-
218217
return title
219218

220219
def init_shapes_graph(self) -> Graph:
221220
"""Initialize SHACL shapes graph"""
222-
shapes_graph = Graph()
223-
shapes_graph.add((URIRef(self.shapes_graph_iri), RDF.type, SHUI.ShapeCatalog))
221+
shapes_graph = Graph().add((URIRef(self.shapes_graph_iri), RDF.type, SHUI.ShapeCatalog))
224222
shapes_graph.add(
225223
(
226224
URIRef(self.shapes_graph_iri),
@@ -240,6 +238,7 @@ def iri_list_to_filter(iris: list[str], name: str = "property", filter_: str = "
240238
if not iris:
241239
return ""
242240
iris_quoted = [f"<{_}>" for _ in iris]
241+
243242
return f"FILTER (?{name} {filter_} ({', '.join(iris_quoted)}))"
244243

245244
def get_class_dict(self) -> dict:
@@ -292,6 +291,7 @@ def create_shapes(self, shapes_graph: Graph) -> tuple[Graph, int]:
292291
node_shape_uri = URIRef(f"{format_namespace(self.shapes_graph_iri)}{class_uuid}")
293292

294293
if class_uuid not in class_uuids:
294+
shapes_count += 1
295295
shapes_graph.add((node_shape_uri, RDF.type, SH.NodeShape))
296296
shapes_graph.add((node_shape_uri, SH.targetClass, URIRef(cls)))
297297
name = self.get_name(cls)
@@ -304,7 +304,6 @@ def create_shapes(self, shapes_graph: Graph) -> tuple[Graph, int]:
304304
NAMESPACE_URL, f"{prop['property']}{'inverse' if prop['inverse'] else ''}"
305305
)
306306
property_shape_uri = URIRef(f"{format_namespace(self.shapes_graph_iri)}{prop_uuid}")
307-
308307
if prop_uuid not in prop_uuids:
309308
shapes_count += 1
310309
name = self.get_name(prop["property"])
@@ -332,7 +331,6 @@ def create_shapes(self, shapes_graph: Graph) -> tuple[Graph, int]:
332331
shapes_graph.add((property_shape_uri, SH.name, Literal(name, lang="en")))
333332
shapes_graph.add((property_shape_uri, RDFS.label, Literal(name, lang="en")))
334333
prop_uuids.add(prop_uuid)
335-
336334
shapes_graph.add((node_shape_uri, SH.property, property_shape_uri))
337335

338336
return shapes_graph, shapes_count

cmem_plugin_shapes/prefix_cc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@
622622
"ddl": "http://purl.org/vocab/riro/ddl#",
623623
"ddpheno": "http://purl.obolibrary.org/obo/DDPHENO_",
624624
"dead": "http://utpl.edu.ec/sbc/data/",
625+
"debias": "http://data.europa.eu/c4p/data/",
625626
"decision": "https://decision-ontology.googlecode.com/svn/trunk/decision.owl#",
626627
"decl": "http://www.linkedmodel.org/1.0/schema/decl#",
627628
"decprov": "http://promsns.org/def/decprov#",
@@ -1784,6 +1785,7 @@
17841785
"nsg": "https://neuroshapes.org/",
17851786
"nsl": "http://purl.org/ontology/storyline/",
17861787
"nsogi": "http://prefix.cc/nsogi:",
1788+
"nsprov": "http://www.w3.org/ns/prov#",
17871789
"nt": "http://ns.inria.fr/nicetag/2010/09/09/voc#",
17881790
"ntag": "http://ns.inria.fr/nicetag/2010/09/09/voc#",
17891791
"ntp": "https://schema.finto.fi/ntp#",
@@ -2560,7 +2562,7 @@
25602562
"sct": "http://snomed.info/id/",
25612563
"scufl2": "http://ns.taverna.org.uk/2010/scufl2#",
25622564
"scv": "http://purl.org/NET/scovo#",
2563-
"sd": "https://w3id.org/okn/o/sd#",
2565+
"sd": "http://www.w3.org/ns/sparql-service-description#",
25642566
"sdgp": "http://stats.data-gov.ie/property/",
25652567
"sdl": "http://purl.org/vocab/riro/sdl#",
25662568
"sdm": "https://w3id.org/okn/o/sdm#",
@@ -3215,6 +3217,7 @@
32153217
"vr": "https://www.w3.org/2018/credentials/v1/",
32163218
"vra": "http://purl.org/vra/",
32173219
"vrank": "http://purl.org/voc/vrank#",
3220+
"vrti": "https://www.w3id.org/virtual-treasury/ontology#",
32183221
"vs": "http://www.w3.org/2003/06/sw-vocab-status/ns#",
32193222
"vsao": "http://purl.obolibrary.org/obo/VSAO_",
32203223
"vsearch": "http://vocab.sti2.at/vsearch#",

0 commit comments

Comments
 (0)