emmo-repo / EMMOntoPy

Library for representing and working with ontologies in Python
https://emmo-repo.github.io/EMMOntoPy
BSD 3-Clause "New" or "Revised" License
40 stars 9 forks source link

Check out how to get version of ontology #299

Closed francescalb closed 2 years ago

francescalb commented 2 years ago

Currently get_ontology of emmo-inferred (latest-stable) fails as versionIRI is missing. Look into how to make better error message and perhaps infer from other tags if versionIRI is missing.

Also ontoversion fails and must be checked.

francescalb commented 2 years ago

There is already a sufficient error message in ontology.get_version(), which is: TypeError: No versionIRI in Ontology

Inferring from other tags I think is a bad idea as this will open up for mistakes that are difficult to track later.

The default version in ontoversion should be ttl, and it would be nice to have a better error message here, that suggests including format.

CasperWA commented 2 years ago

Determine whether versionInfo or versionIRI should be the higher source of truth. And at least use both to try and determine the version.

francescalb commented 2 years ago

@jesper-friis

I want to add the possibility of getting the version from the versionInfo as well as from the versionIRI. Which one do you think should have precedence?

jesper-friis commented 2 years ago

Since the semantics of owl:versionInfo is not well defined on https://www.w3.org/TR/owl-ref/#versionInfo-def, I think versionIRI should have precedence.

However, on https://www.w3.org/TR/2004/REC-owl-guide-20040210/#OntologyVersioning they indicate that owl:versionInfo can be used by versioning systems. So good practice is probably to set owl:versionInfo to the version number (without any prepended "v").

francescalb commented 2 years ago

OK, from the above discussion I propose to do as follows:

if as_iri:
     return VersionIRI of versionIRI else Exception versionIRImissing
else:
    if version_iri:
        return version inferred from version_iri and base_iri
    elif versionInfo:
         return versionINFO
    else:
        raise NoVersionInfoFound....

I guess, then the only reason make this change is to find version from versionInfo if the ontology is malformed and does not have versionIRI (which it should have). Comments?

francescalb commented 2 years ago

@jesper-friis , you were quick on approving the draft, can you please comment on this?