I'm using Jena 3.17.  What does work for me is creating an OntModel with no parameter, "OntModel m = ModelFactory.createOntologyModel();"

   @prefix owl: <http://www.w3.org/2002/07/owl#> .
   @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
   @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
   @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

   <http://ex.org/A>  a <http://ex.org/A> , owl:Class .

Out of curiosity, I wrote the same thing in .ofn format and then had Protege output it in .ttl.

   Prefix(:=<http://ex.org/#>)
   Ontology(<http://ex.org/>
         Declaration( Class( :A ) )
         ClassAssertion( :A :A ))

Protege added  ":A rdf:type owl:NamedIndividual ,  :A ." The semantics are not OWL 1, but I'm not sure if the declarations themselves are legal w.r.t. the OWL 1 language specification.  It does raise the question of whether the createOntologyModel result (that avoids the exception) would be fully sufficient for openllet reasoning.

On 10/25/2021 2:14 AM, Dave Reynolds wrote:
On 24/10/2021 20:33, Steve Vestal wrote:
I tried the following.  All get a ConversionException.

     //public static final OntModelSpec INFERENCE_RULES = OntModelSpec.OWL_DL_MEM;      public static final OntModelSpec INFERENCE_RULES = OntModelSpec.OWL_MEM;      //public static final OntModelSpec INFERENCE_RULES = OntModelSpec.OWL_MEM_MICRO_RULE_INF;      //public static final OntModelSpec INFERENCE_RULES = OntModelSpec.OWL_MEM_MINI_RULE_INF;      //public static final OntModelSpec INFERENCE_RULES = OntModelSpec.OWL_LITE_MEM;

Odd. I had tried what I thought was your test case before answering.

        OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
        String uri = "http://ex.org/A";;
        OntClass cls = m.createClass(uri);
        cls.createIndividual(uri);
        System.out.println("Test model " + uri);
        m.write(System.out, "Turtle");

works for me with current Jena. Giving:

Test model http://ex.org/A
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://ex.org/A>  rdf:type <http://ex.org/A> , owl:Class .

Dave


On 10/24/2021 1:28 PM, Dave Reynolds wrote:
On 24/10/2021 12:42, Steve Vestal wrote:
I omitted a detail that seems to be important.

                         //OntModel m = ModelFactory.createOntologyModel();                          OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
                         String uri = "http://ex.org/A";;
                         OntClass cls = m.createClass(uri);
                         cls.createIndividual(uri);
                         System.out.println("Test model " + uri);
                         m.write(System.out, "Turtle");

If I run the version without an OntModelSpec, it works.  If I run the version with OntModelSpec.OWL_DL_MEM, then I get a ConversionException. I am running Jena 3.17.

Use the OWL_MEM* OntModelSpecs not OWL_DL_MEM. OWL_MEM is set up to support OWL Full and so allows punning.

OWL_MEM itself does not include any reasoner configuration, but then none is needed for this test case case. The OWL_MEM rule reasoner configurations support various subsets of OWL full so are also compatible with punning.

The Javadoc says the default is a "weak reasoner."  I may be able to work around this in this one app, but I'm wondering what will happen when the model is later loaded with another choice of reasoner such as OWL_DL_MEM or Openllet.

OWL_DL_MEM doesn't include any reasoner, I can't speak to what Openllet supports in the way of punning.

Dave

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to