Missing Individuals after creation

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

Missing Individuals after creation

Luis Antonio Rodriguez
Hi, i have a code to create an individual in an existent owl file, in my filesystem:

from owlready2 import *

ontology = get_ontology("file:///home/rodriguezlaar/Doutorado_2023/Only_Dev_Codigo_Fonte/Testing_Build_2/Creating_Individuals_BUILD_2.owl").load()

john = ontology.Classe_Teste(name = "João")

ontology.save(file="Creating_Individuals_BUILD_2.owl", format = "rdfxml")

print(list(ontology.individuals())) # HERE i have a positive result.

I'm trying to replace the open ontology, or to save the ontology with the same name.

After that when I go to the OWL file and open it in Protegé, the created individual is not there.

I'm using 0.41 version.

What is the problem?
Reply | Threaded
Open this post in threaded view
|

Re: Missing Individuals after creation

Jiba
Administrator
Hi,

I tested it but I cannot reproduce the problem.

Are you sure you are writing on the right file? In ontology.save() you give a relative filename (without path) so it might be located on a different directory. You may try with an absolute path (= /home/rodriguezlaar/Doutorado_2023/Only_Dev_Codigo_Fonte/Testing_Build_2/Creating_Individuals_BUILD_2.owl).

Can you look at the file Creating_Individuals_BUILD_2.owl in a text editor, and see whether Owlready2 modified the file ? If the file is produced by Protégé, there are lots of comments in it and, in particular at the end the the file, you should see "Generated by the OWL API". If Owlready2 generated the file, there are no such comments.

Jiba