Skip to content

Commit

Permalink
clean up PARAM triples
Browse files Browse the repository at this point in the history
  • Loading branch information
gtfierro committed Dec 3, 2024
1 parent 5de8c11 commit 2b44be7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions buildingmotif/ingresses/semantic_graph_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ def graph(self, ns: Namespace) -> Graph:
# if the evaluation returns a Template, we need to mint new URIs in the given namespace
# for any unbound parameters. If it returns a Graph, we can just add it to the output.
if isinstance(ev, Template):
# remove all triples where either the subject or object is in the PARAM namespace
for s, p, o in ev.body:
if str(s).startswith(str(ns.PARAM)) or str(o).startswith(str(ns.PARAM)):
ev.body.remove((s, p, o))
graph = ev.body
else:
graph = ev
# remove all triples where either the subject or object is in the PARAM namespace
for s, p, o in graph:
if str(s).startswith(str(ns.PARAM)) or str(o).startswith(str(ns.PARAM)):
logger.info(f"Removing triple {s} {p} {o}")
graph.remove((s, p, o))
logger.info(f"Adding graph with {len(graph)} triples to output")
g += graph
return g

0 comments on commit 2b44be7

Please sign in to comment.