Skip to content

Commit

Permalink
Fix Cyclic imports and missing declarations cause parsing error #798
Browse files Browse the repository at this point in the history
Ontology A imports ontology B, ontology B imports ontoloy A and ontology
C, ontology C provides declaration for property P, ontology A uses
property P.

When loading A through its IRI, an ontology rename failure exception is
raised. the reason is that A is parsed twice, once before and once after
ontology C is parsed. However, when ontology C has yet to be parsed,
there is no declaration available for P. This means that P is assumed to
be an annotation property (only possible assumption, as the alternative
is to throw a parsing error), and when the parsing of A completes, its
id needs to be set with the value read from the ontology.

However, at this point the two ontologies have the same id but not the
same content - P has one guessed type and one parsed type, and the
corresponding axioms differ. Hence, the api interprets this as two
diffrent ontologies with the same id - which cannot coexist in the same
manager.

The full solution for this is for the parsers to work on two levels:
ontology imports closure and entity declarations parsing, and axiom
parsing. The ontologies to import and the declarations in each ontology
would be parsed first, and once the closure has been computed, each
ontology can be parsed with full knowledge of the entities declared -
this removes the source of the error, in that there won't be any more
cases of entities being used when their declaration has not been
processed yet due to imports resolution and cycles. (This is how parsing
is outlined in the specs, but it's not working exactly this way in
practice and it's a considerable refactor for the current parsers.)

(Other root issue: cycles in imports, this is not an indicator of a
healthy ontology structure. It's allowed in OWL 2, but I cannot think of
a scenario where the ontolgies wouldn't be easier to work with with
imports refactored to not be cyclic).

Luckily, when loading by IRIs, it's easy to avoid double parsing by
adding the root ontology used at load time to the map of ontologies
being imported, which is currently used to skip ultiple imports in the
imports closure. The root was not included in this mechanism, for some
reason - it should have been. Removing double parsing removes both
issues, however the problem remains for root ontologies loaded from file
or stream.
  • Loading branch information
ignazio1977 committed Mar 3, 2019
1 parent 6f1a11c commit 68868b9
Showing 1 changed file with 174 additions and 119 deletions.
Loading

0 comments on commit 68868b9

Please sign in to comment.