simphony-osp icon indicating copy to clipboard operation
simphony-osp copied to clipboard

Util function for querying which classes are interconnected

Open pablo-de-andres opened this issue 3 years ago • 0 comments

Related to #443, I think something along these lines could prove quite useful:

from osp.core.ontology.oclass_restriction import RTYPE, Restriction
def get_ontology_connections(subject, object):
    for ax in subject.axioms:
        if not isinstance(ax, Restriction) or \
           ax.rtype == RTYPE.ATTRIBUTE_RESTRICTION:
            continue
        if object.is_subclas_of(ax.target):  # Alternatively if object == ax.target:
            yield ax.relationship

pablo-de-andres avatar Mar 03 '21 11:03 pablo-de-andres