Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubObjectPropertyOf axioms are somewhat complex #19

Open
cmungall opened this issue Aug 5, 2021 · 2 comments
Open

SubObjectPropertyOf axioms are somewhat complex #19

cmungall opened this issue Aug 5, 2021 · 2 comments

Comments

@cmungall
Copy link
Collaborator

cmungall commented Aug 5, 2021

Parsing this:

SubObjectPropertyOf(:activity :influencer)

yields this axiom object:

SubObjectPropertyOf(subObjectPropertyExpression=SubObjectPropertyExpression(v=ObjectPropertyExpression(v=ObjectProperty(v=':activity'))), superObjectPropertyExpression=ObjectPropertyExpression(v=ObjectProperty(v=':influencer')), annotations=[])

This is kinda awkward to work with. All I want to do is reconstruct a basic property hierarchy, as shown here:

image

(this is prov)

My code is already quite complex:

if isinstance(a, SubObjectPropertyOf):
                print(f'SUB: {a}')
                if isinstance(a.subObjectPropertyExpression, ObjectProperty):
                    child = self.iri_to_name(a.subObjectPropertyExpression)
                    if isinstance(a.superObjectPropertyExpression, ObjectProperty):
                        parent = self.iri_to_name(a.superObjectPropertyExpression)
                        print(f'{child} < {parent}')
                        slot_isamap[child].add(parent)
                    else:
                        logging.error(f"cannot handle anon parent properties for {a}")
                else:
                    print(f"cannot handle anon child properties for {a}")

but this doesn't work as it seems I have to check various levels of .v objects?

@cmungall
Copy link
Collaborator Author

cmungall commented Aug 5, 2021

I figured out how to do it:

if isinstance(a, SubObjectPropertyOf):
                sub = a.subObjectPropertyExpression.v
                if isinstance(sub, ObjectPropertyExpression) and isinstance(sub.v, ObjectProperty):
                    child = self.iri_to_name(sub.v)
                    sup = a.superObjectPropertyExpression.v
                    if isinstance(sup, ObjectPropertyExpression) and isinstance(sup.v, ObjectProperty):
                        parent = self.iri_to_name(sup.v)
                        print(f'{child} < {parent}')
                        slot_isamap[child].add(parent)
                    else:
                        logging.error(f"cannot handle anon parent properties for {a}")
                else:
                    print(f"cannot handle anon child properties for {a}")

but this seems a little complex

@hsolbrig
Copy link
Collaborator

hsolbrig commented Apr 9, 2022

Lets use this as one of the first tests for issue #42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants