Hello Jiba,
funny enough, I indeed have already implemented somewhat similar routine which appears to be working. However, this workaround implicitly introduce an overhead. Please consider the following scenario if you are interested in:
1) Let's say we have many (>10^6)
As each of which has
A.owl => family.Person
A.instances => {family.X, family.Y} where family.X and family.Y are instances/individuals belong to A.owl. We call such A as a
concept object.
2) Such concept objects are not contained in the originally given ontology as we generate them by applying logical operations [1]. Consequently, instances/individuals in A.instances do not have type information (.is_a()) of newly generated concepts [2]. Besides, I must admit that I like .is_a() convention a lot as it can be used for instances as well as classes :)
3) After some computation, we would like to serialise some concept objects.
4) In the serialisation phase, we have to include the type information of instances belonging to newly generated concept objects explicitly and then save the ontology. By doing so, we can save/serialise/store information that is encoded in newly generated concept objects.
for A in selected_concepts:
for i in A.instances:
i.is_a.append(A.owl)
This would be very time consuming.
5) In the deserialization phase, we simply load all classes and fill concept objects
Cheers,
Caglar Demir
[1]
https://owlready2.readthedocs.io/en/latest/restriction.html#logical-operators-intersection-union-and-complement[2]
https://pythonhosted.org/Owlready2/class.html#mutli-class-individuals