Inconsistent URL in the imported ontologies

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

Inconsistent URL in the imported ontologies

lesterlyu

Issue description:

When creating a new ontology via owlready2 and set the imported ontologies:
```
from owlready2 import *

onto = default_world.get_ontology("http://test#")

cwrc_onto = default_world.get_ontology("http://sparql.cwrc.ca/ontologies/cwrc.owl").load()
onto.imported_ontologies.append(cwrc_onto)
onto.save('./test.owl')
```

The import section in the owl file does not contain the ".owl" extension:
<owl:Ontology rdf:about="http://test">
  <owl:imports rdf:resource="http://sparql.cwrc.ca/ontologies/cwrc"/>  <-- missing .owl
</owl:Ontology>

This will make Protege unable to read the imported ontology file. Manually add the ".owl" makes it work.

 What's the expected result?

<owl:Ontology rdf:about="http://test">
  <owl:imports rdf:resource="http://sparql.cwrc.ca/ontologies/cwrc.owl"/>
</owl:Ontology>

Additional Information:

If I don't call `load()`, the ".owl" extension won't be removed.

Reply | Threaded
Open this post in threaded view
|

Re: Inconsistent URL in the imported ontologies

Jiba
Administrator
Hi,

Owlready removes the ".owl" at the end of the IRI, because the ontology IRI (as defined in the ontology itself) does not include ".owl". However, this prevent loading the ontology if it is imported by another one, as you noticed.

To fix the problem, in the development version of Owlready, when the IRI itself does not yield an OWL file, I've automatically added .owl, .rdf or .xml to ontology IRI. Thus, you can  now use the true IRI of the ontology (without .owl):

cwrc_onto = default_world.get_ontology("http://sparql.cwrc.ca/ontologies/cwrc").load()

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Inconsistent URL in the imported ontologies

lesterlyu
This post was updated on .
Hi Jiba,

I installed the latest development version via
`pip install git+https://bitbucket.org/jibalamy/owlready2.git`


Owlready2 is now able to open the imported ontology by trying out the three file extensions.
Is it possible to add the file extension in the owl:imports property in the output owl file? This will make other applications, i.e. Protege, to open the owl file exported from owlready2.

<owl:Ontology rdf:about="http://test">
  <owl:imports rdf:resource="http://sparql.cwrc.ca/ontologies/cwrc"/>  <-- missing .owl
</owl:Ontology>


---
The library also have a issue of handling HTTPS request when loading ontology 'http://sparql.cwrc.ca/ontologies/cwrc.owl'.
Please see the fix here.

Thanks,
Lester

Reply | Threaded
Open this post in threaded view
|

Re: Inconsistent URL in the imported ontologies

Jiba
Administrator
Yes, this is indeed the expected behaviour, because the "true" IRI of the ontology is without the ".owl" (it is the IRI is present inside the OWL file).

The change in the development version makes Owlready able to download "http://sparql.cwrc.ca/ontologies/cwrc.owl", despite the IRI is "http://sparql.cwrc.ca/ontologies/cwrc". Thus, you shoul dnow be able to load the ontology that import it, and the right file will be downloaded.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Inconsistent URL in the imported ontologies

lesterlyu
This post was updated on .
I understand the ontology IRI is without the ".owl", but the owl:imports property can also associates with the ontology location which specifies where the ontology is to be imported for the case where the ontology IRI is different from the ontology location. Although ideally the ontology IRI should be the same as the ontology location.
Reply | Threaded
Open this post in threaded view
|

Re: Inconsistent URL in the imported ontologies

Jiba
Administrator
I fully agree that the ontology IRI should be the same as the ontology location, however, it is not the case for CWRC :-(

Using owl:import to indicate the ontology URL instead of its IRI is problematic, because it requires to store the URL in addition to the IRI -- but how to store this additional data in the quadstore without adding e.g. an annotation on the ontology, and thus modifying it ? The only solution would be to add a new table in the database specifically for that case...

Jiba