How to store an instance with different ONTOLOGY Prefix.

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

How to store an instance with different ONTOLOGY Prefix.

Richu
How to store an instance with different ONTOLOGY Prefix.

Suppose an ontology is named "MainOntology" and the other ontology is named "SubOntology". If I want to store the instances within SubOntology where the instances are rdf:type of MainOntology.

Do you think this is possible?

Thanks so much in advance.

Kind regards,
Mayank Singh
Reply | Threaded
Open this post in threaded view
|

Re: How to store an instance with different ONTOLOGY Prefix.

Jiba
Administrator
Hi,

You can do this easily, by creating 2 ontologies.

Here is an example :


from owlready2 import *

main_onto = get_ontology("http://test.org/main_ontology.owl")
sub_onto  = get_ontology("http://test.org/sub_ontology.owl")

with main_onto:
    class MyClass(Thing): pass

sub_onto.imported_ontologies.append(main_onto) # Not strictly needed
with sub_onto:
    my_instance = MyClass()

main_onto.save("/tmp/main_onto.owl")
sub_onto .save("/tmp/sub_onto.owl")


Jiba
Reply | Threaded
Open this post in threaded view
|

Re: How to store an instance with different ONTOLOGY Prefix.

Richu
Thank you so much for your help as always! :D