Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _add_measures(self):
# measures inference
for classname, substances in self.measures_properties.items():
# find entities with substances and instantiate the class
qstr = "select ?inst where {\n"
for substance in substances:
qstr += f" ?inst brick:measures <{substance}> .\n"
qstr += "}"
for row in self.g.query(qstr):
inst = row[0]
self.g.add((inst, RDF.type, classname))
# find entities of the class and add the substances
qstr = f"""SELECT ?inst WHERE
{{ ?inst rdf:type/rdfs:subClassOf* <{classname}>
}}"""
for row in self.g.query(qstr):
inst = row[0]
for substance in substances:
self.g.add((inst, BRICK.measures, substance))