How to use the brickschema.brickschema.namespaces.BRICK 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
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))
github BrickSchema / Brick / brickschema / brickschema / graph.py View on Github external
"""
        Wrapper class and convenience methods for handling Brick models
        and graphs.

        Keyword Args:
            load_brick (bool): if True, loads Brick ontology into graph

        Returns:
            graph (Graph): Graph object
        """
        self.g = rdflib.Graph()
        self.g.bind('rdf', ns.RDF)
        self.g.bind('owl', ns.OWL)
        self.g.bind('rdfs', ns.RDFS)
        self.g.bind('skos', ns.SKOS)
        self.g.bind('brick', ns.BRICK)
        self.g.bind('tag', ns.TAG)

        if load_brick:
            # get ontology data from package
            data = pkgutil.get_data(__name__, "ontologies/Brick.ttl").decode()
            # wrap in StringIO to make it file-like
            self.g.parse(source=io.StringIO(data), format='turtle')
github BrickSchema / Brick / brickschema / brickschema / inference.py View on Github external
} UNION {
              BIND (brick:measures as ?p)
              ?node owl:onProperty ?p.
              ?node owl:hasValue ?o.
          } UNION {
              BIND (rdf:type as ?p)
              ?node owl:onProperty ?p.
              ?node owl:hasValue ?o.
          }
        }""")
        self.tag_properties = defaultdict(list)
        self.measures_properties = defaultdict(list)
        self.grouped_properties = defaultdict(list)

        for (classname, prop, obj, groupname) in res:
            if prop == BRICK.hasTag:
                self.tag_properties[classname].append(obj)
            elif prop == BRICK.measures:
                self.measures_properties[classname].append(obj)
            self.grouped_properties[(classname, groupname)].append((prop, obj))