How to use the brickschema.brickschema.graph.Graph 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 __init__(self):
        """
        Creates a new OWLRL Inference session
        """
        self.g = Graph(load_brick=True)
github BrickSchema / Brick / brickschema / brickschema / inference.py View on Github external
def __init__(self):
        """
        Creates a new OWLRL Inference session
        """
        self.g = Graph(load_brick=True)
github BrickSchema / Brick / brickschema / brickschema / inference.py View on Github external
def __init__(self):
        """
        Creates new Tag Inference session
        """
        self.g = Graph(load_brick=True)
        # get ontology data from package
        data = pkgutil.get_data(__name__, "ontologies/taglookup.pickle")
        # TODO: move on from moving pickle to something more secure?
        self.lookup = pickle.loads(data)
github BrickSchema / Brick / brickschema / brickschema / inference.py View on Github external
def infer_model(self, model):
        """
        Produces the inferred Brick model from the given Haystack model

        Args:
            model (dict): a Haystack model
        """
        entities = model['rows']
        # index the entities by their ID field
        entities = {e['id'].replace('"', ''): {'tags': e} for e in entities}
        brickgraph = Graph(load_brick=True)

        # marker tag pass
        for entity_id, entity in entities.items():
            marker_tags = {k for k, v in entity['tags'].items()
                           if v == 'm:' or v == 'M'}
            for f in self._filters:
                marker_tags = list(filter(f, marker_tags))
            # translate tags
            entity_tagset = list(map(lambda x: self._tagmap[x.lower()]
                                     if x in self._tagmap else x, marker_tags))
            # infer tags for single entity
            triples, _ = self.infer_entity(entity_tagset, identifier=entity_id)
            brickgraph.add(*triples)

        # take a pass through for relationships
        for entity_id, entity in entities.items():
github BrickSchema / Brick / brickschema / brickschema / inference.py View on Github external
def __init__(self):
        """
        Creates a new OWLRL Inference session
        """
        self.g = Graph(load_brick=True)