javaowl-api

Handling undeclared property in load ontology like in Protege


How can I reproduce the way Protege load ontology using owlapi in java? Like when I use:

ontologyBase = ontologyManager.loadOntologyFromOntologyDocument(inFile);

Result in:

[main] WARN org.semanticweb.owlapi.rdf.rdfxml.parser.Translators - Property http://www.example.com/individual/prp#keyPA is undeclared at this point in parsing: typing as OWLDataProperty
[main] WARN org.semanticweb.owlapi.rdf.rdfxml.parser.Translators - Property http://www.example.com/individual/prp#keyPB is undeclared at this point in parsing: typing as OWLDataProperty

The undeclared property get declared as OWLDataProperty, but Protege load ontology result in declaring it as OWLAnnotationProperty.

EDIT: The Ontology:

<http://www.example.com/individual/prp#keyC> <http://www.w3.org/2002/07/owl#hasKey> <http://www.example.com/individual/prp#keyU> .
<http://www.example.com/individual/prp#keyU> <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://www.example.com/individual/prp#keyPA> .
<http://www.example.com/individual/prp#keyU> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.example.com/individual/prp#keyEA> .
<http://www.example.com/individual/prp#keyEA> <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://www.example.com/individual/prp#keyPB> .
<http://www.example.com/individual/prp#keyEA> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
<http://www.example.com/individual/prp#keyX> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.com/individual/prp#keyC> .
<http://www.example.com/individual/prp#keyX> <http://www.example.com/individual/prp#keyPA> <http://www.example.com/individual/prp#keyZA> .
<http://www.example.com/individual/prp#keyX> <http://www.example.com/individual/prp#keyPB> <http://www.example.com/individual/prp#keyZB> .
<http://www.example.com/individual/prp#keyY> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.com/individual/prp#keyC> .
<http://www.example.com/individual/prp#keyY> <http://www.example.com/individual/prp#keyPA> <http://www.example.com/individual/prp#keyZA> .
<http://www.example.com/individual/prp#keyY> <http://www.example.com/individual/prp#keyPB> <http://www.example.com/individual/prp#keyZB> .

Solution

  • The axioms parsed from your example ontology are as follows:

    HasKey(<http://www.example.com/individual/prp#keyC> () (<http://www.example.com/individual/prp#keyPA> <http://www.example.com/individual/prp#keyPB> ))
    ClassAssertion(<http://www.example.com/individual/prp#keyC> <http://www.example.com/individual/prp#keyX>)
    ClassAssertion(<http://www.example.com/individual/prp#keyC> <http://www.example.com/individual/prp#keyY>)
    AnnotationAssertion(<http://www.example.com/individual/prp#keyPA> <http://www.example.com/individual/prp#keyY> <http://www.example.com/individual/prp#keyZA>)
    AnnotationAssertion(<http://www.example.com/individual/prp#keyPA> <http://www.example.com/individual/prp#keyX> <http://www.example.com/individual/prp#keyZA>)
    AnnotationAssertion(<http://www.example.com/individual/prp#keyPB> <http://www.example.com/individual/prp#keyY> <http://www.example.com/individual/prp#keyZB>)
    AnnotationAssertion(<http://www.example.com/individual/prp#keyPB> <http://www.example.com/individual/prp#keyX> <http://www.example.com/individual/prp#keyZB>)
    

    The warning is about undeclared properties that are being provisionally typed as data properties. The parser guesses and, if no axiom found disproves the type guess, the type will be retained. But in this case that doesn't happen (there's a use of an individual as object of the property), so the guess is discarded.

    In other words, your code is parsing the ontology exactly like Protege is.