owlcs / owlapi

OWL API main repository
822 stars 315 forks source link

Undeclared property used in axiom annotation causes unparsed triple warning #1026

Open alanruttenberg opened 2 years ago

alanruttenberg commented 2 years ago

Found when loading into Protege. Loading test case writes INFO to the log because hasDbXref, use in axiom annotations, is not declared as an annotation property. The axiom annotation do not appear when viewing, e.g., the class 'female organism'.

It's not clear to me what the right behavior is here. The spec says: "The axiom closure Ax of each OWL 2 DL ontology O MUST satisfy the typing constraints of OWL 2 DL." but then later says "Although declarations are not always required, they can be used to catch obvious errors in ontologies" suggesting ... declarations are not always required.

In this case the type should be inferred from the context - it is an axiom annotation and so the property should be understood as an annotation property.

   INFO  15:54:22  Unparsed triple: _:genid2147483649 -> http://www.geneontology.org/formats/oboInOwl#hasDbXref -> uk.ac.manchester.cs.owl.owlapi.OWLLiteralImplString@b4f3fce3
   INFO  15:54:22  Unparsed triple: _:genid2147483648 -> http://www.geneontology.org/formats/oboInOwl#hasDbXref -> uk.ac.manchester.cs.owl.owlapi.OWLLiteralImplString@b4f3fce3
   INFO  15:54:22  Unparsed triple: _:genid2147483650 -> http://www.geneontology.org/formats/oboInOwl#hasDbXref -> uk.ac.manchester.cs.owl.owlapi.OWLLiteralImplString@b4f3fce3
ignazio1977 commented 2 years ago

I think the relevant spec bit is this:

The typing constraints thus ensure that the sets of IRIs used as object, data, and annotation properties in O are disjoint and that, similarly, the sets of IRIs used as classes and datatypes in O are disjoint as well. These constraints are used for disambiguating the types of IRIs when reading ontologies from external transfer syntaxes. All other declarations are optional.

This leaves the declaration of named individuals as optional - and in fact the example after

Although declarations are not always required

shows named individuals as examples.

Re inferring types from usage, that works for some axioms but not all, depending on syntax. Functional syntax is never ambiguous in this respect, IIRC; other syntaxes, RDF based ones certainly, are ambiguous in many cases, so there can't be a general rule as to what can be inferred. In strict mode, guessing types should never be necessary.

So, my rule of thumb:

There was a defect fixed recently about triples not consumed (report of unparsed triples is wrong, under certain circumstances). Protege wouldn't be using a fixed OWLAPI version yet, so there's a chance this is a false alarm - I haven't checked your test case yet.