Incorrect owl when saving ontology in rdfxml?

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

Incorrect owl when saving ontology in rdfxml?

fpopineau
Hi all,

Let's try the small example:

from owlready2 import *

onto = get_ontology('http://students.org/') # nouvelle ontologie, on donne son IRI
with onto:
    # Define a Person
    class Person(Thing):  # nouvelle classe sous-classe de Thing
        pass
    
    # Define a Course
    class Course(Thing):
        # subclass of not a Person
        is_a = [Not(onto.Person)]
        
    # AllDisjoint([Person, Course])
    
    # A Person can teach a Course
    class teaches(Person >> Course): pass
    
    # Define a Teacher
    class Teacher(Thing):
        # as a Person who teaches some Course
        equivalent_to = [And([Person, teaches.some(Course)])]
        
    # A Person can attend a Course    
    class attends(Person >> Course): pass
    
    # Define a Student
    class Student(Thing):
        # as a Person who attends some Course
        equivalent_to = [And([Person, attends.some(Course)])]

# Define some individuals
with onto:
    mary = Person(name='mary') # mary instance de la classe personne
    cs600 = Course(name='cs600')
    alice = Person(name='alice')
    alice.teaches = [cs600]
    mary.attends = [cs600]

onto.save('students.owl')

default_world.save('world-students.owl')

When looking into the OWL files, we see that when onto is saved, the base IRI for the class is lost.
In students.owl, we get:
<owl:Class rdf:about="Person">
  <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>
when in world-students.owl we get:
<owl:Class rdf:about="http://students.org/Person">
  <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>

When loading students.owl into Protégé, we end up with 2 Course and 2 Person classes, one with the right IRI and the other one with the file name as IRI, which is unexpected (to me!).

Any reason I may have overlooked for this behavior?

Thanks for any explanation.

Best regards,

Fabrice


Reply | Threaded
Open this post in threaded view
|

Re: Incorrect owl when saving ontology in rdfxml?

Jiba
Administrator
Hi,

The problem is that the ontology IRI ('http://students.org/') is not a full IRI ; Owlready expects a "path" part in the URL. If you replace it by e.g. 'http://students.org/onto.owl', the problem is now fixed.

Note also that saving World in OWL file is supported by Owlready, but may not be supported by other tools, including Protege. An OWL file is expected to contain a single ontology ; when saving World, there can be several ontologies and thus Owlready use full IRI for entities to prevent confusion.

When a single ontology is saved, Owlready abbreviate it (e.g. #Person or Person), which is expected to be added to the ontology IRI. For instance, ontology IRI 'http://students.org/' + entity IRI 'Person' is expected to yield 'http://students.org/Person' -- it seems that, in that case, Protégé does not work as expected and use the ontology filename instead of its IRI, possibly because the IRI misses the path part.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect owl when saving ontology in rdfxml?

fpopineau
This makes sense (a lot :-) ).
Got trapped by this IRI thing.

Thanks a lot and keep up the good work!

Fabrice