Saving New Imported Ontologies

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

Saving New Imported Ontologies

Lindsay
Hi all,

I have been able to create a new ontology and add classes and properties. However I haven't been able to figure out how to save the imported ontologies into the file when onto.save() is called. I set them in python using

onto.imported_ontologies = [list, of, ontologies]

but when I look at the output file, they are not located in the Ontology section of the rdfxml.


Any suggestions?
Reply | Threaded
Open this post in threaded view
|

Re: Saving New Imported Ontologies

Jiba
Administrator
Hi,

I've investigated this problem. In the current version of Owlready, you must use append() to add imported ontologies:

        onto.imported_ontologies.append(onto_2)
        onto.imported_ontologies.append(onto_3)
        ...

Direct assignation to onto.imported_ontologies does not work. I'm going to fix that for future release.

Best regards,
Jean-Baptiste Lamy
MCF, LIMICS, Université Paris 13
Reply | Threaded
Open this post in threaded view
|

Re: Saving New Imported Ontologies

Lindsay
Thanks for the work around!
Reply | Threaded
Open this post in threaded view
|

Re: Saving New Imported Ontologies

Lindsay
In reply to this post by Jiba
Now the ontologies are added when I save from owlready2 to a file but aren't there when I import and print(onto.imported_ontologies). It just shows an empty list. I'm using the RDFXML format.

Is there a different way to access them?
Reply | Threaded
Open this post in threaded view
|

Re: Saving New Imported Ontologies

Sree
what I generally do is onto.save(file = "example.owl"). This definitely won't be an empty list.
I think the same works for RDFXML format too if I'm not wrong.
Reply | Threaded
Open this post in threaded view
|

Re: Saving New Imported Ontologies

Jiba
Administrator
In reply to this post by Lindsay
Hello,

I've tested it, but it seems to work as expected.
I created 2 ontologies with this script:


from owlready2 import *

onto_path.append("/tmp")

o1 = get_ontology("http://www.test.org/o1.owl")
o2 = get_ontology("http://www.test.org/o2.owl")

o1.imported_ontologies.append(o2)

with o1:
  class C1(Thing): pass

with o2:
  class C2(Thing): pass

o1.save()
o2.save()


And then I loaded o1.owl with the following script :


from owlready2 import *

onto_path.append("/tmp")

o1 = get_ontology("http://www.test.org/o1.owl").load()

print(o1.imported_ontologies)


When run, it print the o2 ontology:

[get_ontology("http://www.test.org/o2.owl#")]

Are you sure the problem is not somewhere else?

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

> Now the ontologies are added when I save from owlready2 to a file but aren't
> there when I import and print(onto.imported_ontologies). It just shows an
> empty list. I'm using the RDFXML format.
>
> Is there a different way to access them?
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://owlready.8326.n8.nabble.com/Saving-New-Imported-Ontologies-tp224p235.html
> To start a new topic under Owlready, email [hidden email]
> To unsubscribe from Owlready, visit