onto.save() doesn't work

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

onto.save() doesn't work

Hamico
Hi Jiba,

every time I execute

onto.save(file = "filename or fileobj", format = "rdfxml")

the ontology becomes bigger than usual and I have some problems. The command

onto.save()

doesn't work. I have the following error:

Traceback (most recent call last):
  File "C:/Users/hamico/PycharmProjects/App/Part14/Test.py", line 477, in <module>
    main()
  File "C:/Users/hamico/PycharmProjects/App/Part14/Test.py", line 441, in main
    istanza.insert_element("name_element1", "description_element1")
  File "C:/Users/hamico/PycharmProjects/App/Part14/Test.py", line 76, in inserisci_patologia
    onto.save()
  File "C:\Users\hamico\PycharmProjects\App\venv\lib\site-packages\owlready2\namespace.py", line 802, in save
    file = _open_onto_file(self.base_iri, self.name, "wb")
  File "C:\Users\hamico\PycharmProjects\App\venv\lib\site-packages\owlready2\namespace.py", line 1058, in _open_onto_file
    if (mode.startswith("w")): return open(os.path.join(onto_path[0], "%s.owl" % name), mode)
IndexError: list index out of range

How is possible?

Many thanks.
Best regards,


Hamico
Reply | Threaded
Open this post in threaded view
|

Re: onto.save() doesn't work

Jiba
Administrator
Hi,

ontology.save() with no argument save the ontology in the first path in onto_path. If you did not add any path in onto_path, it cannot be performed and raise the error you obtained.

The ontology becoming bigger is another problem; could you send me an ontology that exhibits this behavior please?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: onto.save() doesn't work

Hamico
This post was updated on .
Hi Jiba,

It's the same ontology I sent you. When I add some data, it becomes bigger. Can it be the difference between the name of namespace (C:/Users/hamico/Desktop/myontology.owl) and the location of the ontology. The saving of ontology replicate the values of some prefixes (xml:base, xmlns, owl:Ontology rdf:about) more times when I execute the scripts on my ontology.

What can I do?

Many thanks.
Best regards,

Hamico
Reply | Threaded
Open this post in threaded view
|

Re: onto.save() doesn't work

Jiba
Administrator
Hi,

One of the problem is that your ontology IRI is relative and not absolute :

 * xml:base="ontopharma.owl" in OWL file).

 * <owl:Ontology rdf:about="ontopharma.owl"/>

As about is relative and xml:base also, both are joined, resulting in ontopharma.owl/ontopharma.owl as full IRI, which is not the intended IRI I suppose.


I've tried to add new individuals, but only triplets related to these individuals are added. Could you send me a small script that creates some data and save the ontology with a bigger size?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: onto.save() doesn't work

Hamico
Hi Jiba,
I have solved.

Many thanks.
Best regards,
Hamico