pydrepr/drepr/models/drepr.py
def is_valid(self):
        """
        Perform a check to see if this D-REPR is valid. Raise AssertionError if this is not valid
        """
        # CHECK 1: all references (resource id, attribute ids) are valid
        resource_ids = {r.id for r in self.resources}
        for pref in self.preprocessing:
            if pref.value.output is not None:
                # preprocessing create new resource
                assert pref.value.output not in resource_ids, "Cannot overwrite existing resources"
                resource_ids.add(pref.value.output)
        attr_ids = {attr.id for attr in self.attrs}

        for attr in self.attrs:
            assert attr.resource_id in resource_ids, f"Attribute {attr.resource_id} does not belong to any resources"
        for align in self.aligns:
            assert align.source in attr_ids and align.target in attr_ids, \
                f"The alignment {align} links to non-existence attributes"

        for node in self.sm.nodes.values():
            if isinstance(node, DataNode):
                assert node.attr_id in attr_ids, f"The semantic model has a link to " \
                                                 f"a non-existence attribute: {node.attr_id}"

        # CHECK 2: check class and predicates are valid
        for node in self.sm.nodes.values():
            if isinstance(node, ClassNode):
                if self.sm.is_rel_iri(node.label):
                    prefix = node.label.split(":", 1)[0]
                    assert prefix in self.sm.prefixes, f"Unknown prefix `{prefix}` of the " \
                                                       f"ontology class {node.label}"
        for edge in self.sm.edges.values():
            if self.sm.is_rel_iri(edge.label):
                prefix = edge.label.split(":", 1)[0]
                assert prefix in self.sm.prefixes, f"Unknown prefix `{prefix}` of the " \
                                                   f"ontology predicate {edge.label}"

        Perform a check to see if this D-REPR is valid. Raise AssertionError if this is not valid
        
Perform a check to see if this D-REPR is valid. Raise AssertionError if this is not valid
Perform a check to see if this D - REPR is valid . Raise AssertionError if this is not valid
def is_valid(self):
        resource_ids = {r.id for r in self.resources}
        for pref in self.preprocessing:
            if pref.value.output is not None:
                assert pref.value.output not in resource_ids, "Cannot overwrite existing resources"
                resource_ids.add(pref.value.output)
        attr_ids = {attr.id for attr in self.attrs}
        for attr in self.attrs:
            assert attr.resource_id in resource_ids, f"Attribute {attr.resource_id} does not belong to any resources"
        for align in self.aligns:
            assert align.source in attr_ids and align.target in attr_ids, \
                f"The alignment {align} links to non-existence attributes"
        for node in self.sm.nodes.values():
            if isinstance(node, DataNode):
                assert node.attr_id in attr_ids, f"The semantic model has a link to " \
                                                 f"a non-existence attribute: {node.attr_id}"
        for node in self.sm.nodes.values():
            if isinstance(node, ClassNode):
                if self.sm.is_rel_iri(node.label):
                    prefix = node.label.split(":", 1)[0]
                    assert prefix in self.sm.prefixes, f"Unknown prefix `{prefix}` of the " \
                                                       f"ontology class {node.label}"
        for edge in self.sm.edges.values():
            if self.sm.is_rel_iri(edge.label):
                prefix = edge.label.split(":", 1)[0]
                assert prefix in self.sm.prefixes, f"Unknown prefix `{prefix}` of the " \
                                                   f"ontology predicate {edge.label}"
def is_valid ( self ) : resource_ids = { r . id for r in self . resources } for pref in self . preprocessing : if pref . value . output is not None : assert pref . value . output not in resource_ids , "Cannot overwrite existing resources" resource_ids . add ( pref . value . output ) attr_ids = { attr . id for attr in self . attrs } for attr in self . attrs : assert attr . resource_id in resource_ids , f"Attribute {attr.resource_id} does not belong to any resources" for align in self . aligns : assert align . source in attr_ids and align . target in attr_ids , f"The alignment {align} links to non-existence attributes" for node in self . sm . nodes . values ( ) : if isinstance ( node , DataNode ) : assert node . attr_id in attr_ids , f"The semantic model has a link to " f"a non-existence attribute: {node.attr_id}" for node in self . sm . nodes . values ( ) : if isinstance ( node , ClassNode ) : if self . sm . is_rel_iri ( node . label ) : prefix = node . label . split ( ":" , 1 ) [ 0 ] assert prefix in self . sm . prefixes , f"Unknown prefix `{prefix}` of the " f"ontology class {node.label}" for edge in self . sm . edges . values ( ) : if self . sm . is_rel_iri ( edge . label ) : prefix = edge . label . split ( ":" , 1 ) [ 0 ] assert prefix in self . sm . prefixes , f"Unknown prefix `{prefix}` of the " f"ontology predicate {edge.label}"
Perform a check to see if this D-REPR is valid.
Perform a check to see if this D - REPR is valid .
"""
        Perform a check to see if this D-REPR is valid. Raise AssertionError if this is not valid
        """ # CHECK 1: all references (resource id, attribute ids) are valid # preprocessing create new resource # CHECK 2: check class and predicates are valid
self