How to use the brickschema.brickschema.namespaces.RDF.type function in brickschema

To help you get started, we’ve selected a few brickschema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BrickSchema / Brick / brickschema / brickschema / inference.py View on Github external
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))