'namespace roundtripping' use case

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

'namespace roundtripping' use case

Mike Bergman
Hi jiba,

You have seen from some recent messages my attempt to get namespaces to work with imports. My objective in all of this has been to be able to: 1) take an existing ontology and extract its classes and properties (I am not working at present with individuals) to flat files; 2) work on the flat files or create new ones; 3) and re-build the revised ontology by reading the flat files. This is a classic 'roundtripping' use case.

This process is not always a "full" one in that sometimes only partial extractions or new reads are part of an 'incremental' build, in which case we don't bootstrap from starting shells but add to an ontology build in-progress.

The initial start of the "full" process is bootstrapped with a stub (rc) and an upper ontology (kko). Thereafter, classes and properties are added to build out the rc ontology structure. The initial rc shell is the host that imports kko. The built ontology thus consists of two primary namespaces, kko for the upper ontology, and rc for the rest.

After the first initial step, the incremental rc ontology is written to file and then used for the next build step. (The rc stub is no longer used; it only applies to the initial bootstrap.) All steps import the same kko upper ontology when loading for a new incremental build step.

The recipe I have finally got to work for full and incremental cases is to assign the identical file name to the ontology IRI of kko and the import statement for kko in rc. Under an incremental build the owlready2 memory model recognizes the kko namespace for new ingests, which is great. However, all intermediate rc files written out after a build step have namespace prefixes dropped.

My request is to enable xlmns declarations, including for imports, to be retained and written to file when saving an ontology. I am familiar with two list postings directly relevant to this request: loading local OWL imports (http://owlready.8326.n8.nabble.com/Loading-OWL-imports-from-local-td1606.html#a1658) and namespace names (http://owlready.8326.n8.nabble.com/Namespace-Name-td1626.html#a1629).

I think I could override the owlready2 code to get these namespaces recognized (http://owlready.8326.n8.nabble.com/override-base-py-abreviated-namespaces-td404.html#a409), but I am leery to change the basic code. I also would prefer to use a IRI v file name for the imported kko upper ontology.

To illustrate what is going on, I post the rdf and ontology headers from the two starting files, and then the exported ontology to file after adding some classes.

I suspect I may have a few errors in my initial declarations. If any are blaring or critical, I'd love to hear of them.

I think owlready2 is fantastic, and I am able to work with it for all of my purposes so far as is. However, this xmlns addition to a future version would make life smoother. ;)

Thanks!

Best, Mike

============

stub: initial rc:
--------------

<rdf:RDF xmlns="http://kbpedia.org/kko/rc/"
     xml:base="http://kbpedia.org/kko/rc/"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:ns="http://creativecommons.org/ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:kko="http://kbpedia.org/ontologies/kko#"
     xmlns:skos="http://www.w3.org/2004/02/skos/core#"
     xmlns:vann="http://purl.org/vocab/vann/"
     xmlns:wikiCategory="http://wikipedia.org/wiki/Category:">
    <owl:Ontology rdf:about="http://kbpedia.org/kbpedia/rc#">
        <owl:versionIRI rdf:resource="http://kbpedia.org/rc/v300"/>
        <owl:imports rdf:resource="https://www.w3.org/2009/08/skos-reference/skos-owl1-dl.rdf"/>
                <owl:imports rdf:resource="file:///C:/1-PythonProjects/kbpedia/v300/build_ins/stubs/kko.owl"/>


imported kko:
-------------

<rdf:RDF xmlns="http://kbpedia.org/ontologies/kko#"
     xml:base="http://kbpedia.org/ontologies/kko"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:ns="http://creativecommons.org/ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:skos="http://www.w3.org/2004/02/skos/core#"
     xmlns:kko="http://kbpedia.org/ontologies/kko#"
     xmlns:wikiCategory="http://wikipedia.org/wiki/Category:"         
     xmlns:rc="http://kbpedia.org/kko/rc/"
     xmlns:vann="http://purl.org/vocab/vann/">
    <owl:Ontology rdf:about="file:///C:/1-PythonProjects/kbpedia/v300/build_ins/stubs/kko.owl">
        <owl:versionIRI rdf:resource="http://kbpedia.org/kko/v300"/>


saved rc after a build step:
--------------------------

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
         xmlns:owl="http://www.w3.org/2002/07/owl#"
         xml:base="http://kbpedia.org/kbpedia/rc"
         xmlns="http://kbpedia.org/kbpedia/rc#"
         xmlns:ns="http://creativecommons.org/ns#"
         xmlns:x_1.1="http://purl.org/dc/elements/1.1/"
         xmlns:vann="http://purl.org/vocab/vann/"
         xmlns:core="http://www.w3.org/2004/02/skos/core#">

<owl:Ontology rdf:about="#">
  <owl:imports rdf:resource="https://www.w3.org/2009/08/skos-reference/skos-owl1-dl.rdf"/>
  <owl:imports rdf:resource="file:///C:/1-PythonProjects/kbpedia/v300/build_ins/stubs/kko.owl"/>
  <owl:versionIRI rdf:resource="http://kbpedia.org/rc/v300"/>
 
Reply | Threaded
Open this post in threaded view
|

Re: 'namespace roundtripping' use case

Jiba
Administrator
Hi,

If I understand well, you would like that the XMLNS definitions (e.g. xmlns:skos, xmlns:kko, etc) are stored somewhere, and then written back when saving the ontology to a file? This sound weird to me, because, for me, all the ontology data should be in the quadstore, as RDF triple. This would introduce some "hidden" stored information, present somewhere in the memory but not in the quadstore.


By the way, IRI using the "file://" protocol are not advised for ontology -- some tools do not recognize them, or inconsistently (either Pellet or Hermit, I don't remind exactly).

I advise to use "true" URL with http:// or https:// (even if the file is not available online, this is not a problem at all).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: 'namespace roundtripping' use case

Mike Bergman
Hi jiba,

Well, maybe the better thing is to simply describe what I want.

In my owlready2 ontologies I load ontologies with namespace prefixes of 'kko' and 'rc'. When I then save those ontologies, and inspect them in Protege, I do not see these prefixes. I can still use the prefixes for interacting directly with owlready2, but not see these prefixes in the editor. It struck me there was some loss in the roundrtip. Let me know if I can provide further details.

Thanks!

Best, Mike
Reply | Threaded
Open this post in threaded view
|

Re: 'namespace roundtripping' use case

Mike Bergman
In reply to this post by Jiba
Hi jiba,

As far as the "file://" v true" URL with http:// or https://, maybe I am not specifying stuff correctly. In my use case, given the options I tried, only "file://" worked for me. Believe me, I would like to avoid any hardwiring of IRIs, so if there is a pattern I should be following, I am happy to drop the file business.

Any instructions?

Thanks,

Best, Mike
Reply | Threaded
Open this post in threaded view
|

Re: 'namespace roundtripping' use case

Jiba
Administrator
In reply to this post by Mike Bergman
Hi,

Possibly you can solve your problem by creating an empty ontology with the desired XML namespace prefixes and importing this ontology, and then never write it Owlready (so as it remains with the prefix, making them available to Protégé) ?

Jiba