Ontology saving error

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

Ontology saving error

Irfan Khan Tanoli
Hi Jean-Baptiste Lamy,

This is my code to load an ontology and when i am trying to save the ontology it raise error.
from owlready2 import *
"""
import types
onto_path.append("file://E:/Dropbox/1.GSSI Courses/3.Project_Code/vocabularies/Paper2_Vocab/")
onto = get_ontology("file://E:/Dropbox/1.GSSI Courses/3.Project_Code/vocabularies/Paper2_Vocab/A1_vocabulary.owl")
onto.load()

print (onto.hasRole)
print(list(onto.classes()))
print(onto.Object.hasCategory)
onto.save()
onto.save(file = "/policy.owl", format = "rdfxml")
"""

ERROR:

Traceback (most recent call last):
  File "C:\Desktop\Python_scripts\ontology_loading.py", line 20, in <module>
    onto.save()
  File "C:\python3.5\lib\site-packages\owlready2\namespace.py", line 514, in save
    file = _open_onto_file(self.base_iri, self.name, "wb")
  File "C:\python3.5\lib\site-packages\owlready2\namespace.py", line 726, in _open_onto_file
    if (mode.startswith("w")): return open(os.path.join(onto_path[0], "%s.owl" % name), mode)
OSError: [Errno 22] Invalid argument: 'file://E:/Dropbox/1.GSSI Courses/3.Project_Code/vocabularies/Paper2_Vocab/A1_vocabulary.owl'

Can you please help me how can i save changes in existing ontology and also how can i save in rdfxml format.

Thanks
Irfan Khan Tanoli
Reply | Threaded
Open this post in threaded view
|

Re: Ontology saving error

Jiba
Administrator
Hello,

The easiest way to save the ontology is to provide an absolute path, for example:

        onto.save(file = "E:/your/path/policy.owl") # For windows

onto_path expects local directory names, not URI, so you need to use :

        onto_path.append("E:/Dropbox/1.GSSI Courses/3.Project_Code/vocabularies/Paper2_Vocab/")

Best regards,
Jean-Baptiste Lamy
MCF, LIMICS, Université Paris 13

> Hi Jean-Baptiste Lamy,
>
> This is my code to load an ontology and when i am trying to save the
> ontology it raise error.
> from owlready2 import *
> """
> import types
> onto_path.append("file://E:/Dropbox/1.GSSI
> Courses/3.Project_Code/vocabularies/Paper2_Vocab/")
> onto = get_ontology("file://E:/Dropbox/1.GSSI
> Courses/3.Project_Code/vocabularies/Paper2_Vocab/A1_vocabulary.owl")
> onto.load()
>
> print (onto.hasRole)
> print(list(onto.classes()))
> print(onto.Object.hasCategory)
> onto.save()
> onto.save(file = "/policy.owl", format = "rdfxml")
> """
>
> ERROR:
>
> Traceback (most recent call last):
>   File "C:\Desktop\Python_scripts\ontology_loading.py", line 20, in <module>
>     onto.save()
>   File "C:\python3.5\lib\site-packages\owlready2\namespace.py", line 514, in
> save
>     file = _open_onto_file(self.base_iri, self.name, "wb")
>   File "C:\python3.5\lib\site-packages\owlready2\namespace.py", line 726, in
> _open_onto_file
>     if (mode.startswith("w")): return open(os.path.join(onto_path[0],
> "%s.owl" % name), mode)
> OSError: [Errno 22] Invalid argument: 'file://E:/Dropbox/1.GSSI
> Courses/3.Project_Code/vocabularies/Paper2_Vocab/A1_vocabulary.owl'
>
> Can you please help me how can i save changes in existing ontology and also
> how can i save in rdfxml format.
>
> Thanks
> Irfan Khan Tanoli
>
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://owlready.8326.n8.nabble.com/Ontology-saving-error-tp103.html
> To start a new topic under Owlready, email [hidden email]
> To unsubscribe from Owlready, visit
Reply | Threaded
Open this post in threaded view
|

Re: Ontology saving error

Irfan Khan Tanoli
In reply to this post by Irfan Khan Tanoli
Thanks. It worked