From 2b44be781d12afce31fac0cc34cba4f0f5e369ce Mon Sep 17 00:00:00 2001 From: Gabe Fierro Date: Mon, 2 Dec 2024 18:30:57 -0700 Subject: [PATCH] clean up PARAM triples --- buildingmotif/ingresses/semantic_graph_synthesis.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/buildingmotif/ingresses/semantic_graph_synthesis.py b/buildingmotif/ingresses/semantic_graph_synthesis.py index 74925ce6..6cb92da1 100644 --- a/buildingmotif/ingresses/semantic_graph_synthesis.py +++ b/buildingmotif/ingresses/semantic_graph_synthesis.py @@ -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