Hello Jean Baptise,
thanks again for implementing the general class axiom, as of now it works beautifully, however I have encountered another challenge that I hope you can help me with. I tried to implement an ontology which shall use an n-ary structure (http://ontologydesignpatterns.org/wiki/Submissions:N-Ary_Relation_Pattern_%28OWL_2%29
) for describing relations between chemical entities. However, I ran into the problem that I could not find the correct file format for loading relations with complex “hasSelf” relations into owlready2. Which should look like the relation depicted below. Here the circle filled with Me1_Sub is a class with should point with the relation has_Me1_en to an individual S_Ni_ind. As this relation shall be generated automatically an additional loop from the individual S_Ni_Ind to itself must be generated for further inferring of axioms.
In Protégé’s OWL Manchester syntax, this would look like this:
However, when I try to load an ontologie in an rdf/xml or owl/xml file format into python using owlready2’s onto.load() I get a relation looking like this:
for rdf xml or like this:
I first found out that this happened after saving the ontology and reopening it in protégé, where the R1_meEn Object-Property had been changed to a class like structure, however I think this only happened due to faulty syntax after saving the ontology.
I tried narrowing the error down as much as possible and think it is a parsing/reading error, where the “hasSelf” relation of the owl2 syntax is not correctly interpreted. As I am not familiar how the conversion process from owl2 file to object-oriented-ontology in python works, I am sorry to tell you that I could not narrow it down further. I also checked the "as_rdflib_graph()" function, to check whether the quadstore is un affected, however this also did not work.
I have used the code given below, with the files you can find attached to this mail in order to produce the error. I made sure to have updated owlready2 to 0.40 and use rdflib in version 6.2.0.
from ontopy import World
from owlready2 import GeneralClassAxiom
owlready2.reasoning.JAVA_MEMORY = 1000
owlready2.JAVA_EXE = 'C:/Users/xxx/Desktop/Protege-5.5.0/jre/bin/java.exe'
world_3 = World()
onto = world_3.get_ontology("C:/Users/xxx/Short_Example_for_Issue_before_loading.rdf")
onto.name = 'onto'
gcas = list(onto.general_class_axioms())
classes = list(onto.classes())
individuals = list(onto.individuals())
object_properties = list(onto.object_properties())
classes_2 = list(onto.classes())
onto.save("C:/Users/xxx/Short_Example_for_Issue_after_saving.rdf", format = "rdfxml")
graph = world_3.as_rdflib_graph()
I don’t know if I have done any mistake myself, by loading in the wrong syntax or by misusing a structure/syntax not meant to be used in such a way. Therefore, I am grateful for any support you can give me. Also, feel free to contact me when you have any questions or if and when I can be of any assistants.