def new_existing_bnode(self, bf_property, rule):
"""Returns existing blank node or a new if it doesn't exist
Args:
bf_property (str): RDF property URI
rule (rdflib.URIRef): RDF subject of the map rule
Returns:
rdflib.BNode: Existing or New blank node
"""
blank_node = None
for row in self.rules_graph.query(HAS_MULTI_NODES.format(rule)):
if str(row[0]).lower().startswith("true"):
return rdflib.BNode()
for subject in self.graph.query(GET_BLANK_NODE.format(bf_property)):
# set to first and exist loop
blank_node = subject[0]
break
if not blank_node:
blank_node = rdflib.BNode()
return blank_node
评论列表
文章目录