not pretty to print compound classes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

not pretty to print compound classes

William
This post was updated on .
Hi~
I often get verbose print result, such as R.only(A|A|B), which is worse than R.only(A|B), and if B is a subclass of A, then a better one is R.only(A). You also might have got And([R.only(A|A|B)], R.only(A|B)]), that is really redundant.

In semantics, A|A == A, they are identified with each other.

One day, I wanted to check that R.value(a) in x.is_instance_of (instead of a in x.R), I printed x.is_instance_of, it shown (partly)
[R.only(A|A|OneOf(a)), R.only(A|OneOf(a))], where a is instance of A, thus it gave me False. It would be a long list in large ontology, but there was no what you looked for yet. I really hope that we define an eazy-using function to check x is instance of y
Reply | Threaded
Open this post in threaded view
|

Re: not pretty to print compound classes

Jiba
Administrator
Hi,

Owlready display the parent classes as they are defined in the quadstore. From a logical point of view, a "perfect" pretty print cannot be achieved without calling a full reasoner. Similarly, if you really want to test whether x is an instance of y, you also need the entire reasoning on the whole ontology (e.g. the reasoner might found that y is equivalent to z, and that x belongs to z, so on).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: not pretty to print compound classes

William
This post was updated on .
Hi~
We can have a sub-perfect pretty print. Transform And-Or expressions to "steam-line-form" as a normal form, e.g.

A & (B|C) | D -> A&B | A& C |D

A & (B|C) | D | C -> A&B | C |D (checking subclass-relation only with equivalence, here C==C)

Further more, we can simplify the list of x.is_instances_of