You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Steve Vestal <st...@adventiumlabs.com> on 2021/10/20 09:39:30 UTC
How to pun a URI?
I am creating an OntClass but also want to pun that IRI, so that I have an
Individual with that same IRI that can be a member of a class. Here is an
example of doing that in OFN (a class that contains itself, sort of but not
really as I understand it), which works in Protege.
Declaration( Class( :myClass ) )
ClassAssertion( :myClass :myClass )
When I try the following two approaches, I get an
org.apache.jena.ontology.ConversionException. How do I make the above
declarations using the Jena APIs?
// punnedClass is an OntClass to be punned
// containingClass is an OntClass to contain the Individual interpretation of
punnedClass
model.createIndividual(punnedClass.getURI(), containingClass);
containingClass.createIndividual(punnedClass.getURI());
Re: How to pun a URI?
Posted by Dave Reynolds <da...@gmail.com>.
On 24/10/2021 15:16, Steve Vestal wrote:
> I searched a bit for a way to declare a HasKey axiom. Does this mean
> that is a futile exercise?
As Lorenz says, there is no API or reasoner support in Jena for OWL 2 so
no there's no convenient API for declaring a HasKey axiom.
HasKey, like all OWL axioms, is expressed syntactically as just a set of
RDF statements so you could manually create the correct triples using
the RDF API which would allow you to create a model that you could
export to other tools. However, there's no reasoner support in Jena
itself for it.
Dave
> On 10/24/2021 6:57 AM, Lorenz Buehmann wrote:
>> yeah, punning is a new feature of OWL 2, Jena does only support OWL 1
>> and some parts of OWL 2. Whether there is a workaround or room for a
>> feature request, Dave Reynolds knows better for sure.
>>
>> On 24.10.21 13:48, Martynas Jusevičius wrote:
>>> Could this be the reason?
>>> “ OWL DL includes all OWL language constructs with restrictions such as
>>> type separation (a class can not also be an individual or property, a
>>> property can not also be an individual or class).”
>>>
>>> https://www.w3.org/TR/owl-guide/
>>>
>>> On Sun, 24 Oct 2021 at 13.43, Steve Vestal
>>> <st...@adventiumlabs.com>
>>> 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. 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.
>>>>
>>>> On 10/20/2021 5:30 AM, Lorenz Buehmann wrote:
>>>>> OntModel m = ModelFactory.createOntologyModel();
>>>>> String uri = "http://ex.org/A";
>>>>> OntClass cls = m.createClass(uri);
>>>>> cls.createIndividual(uri);
>>>>> m.write(System.out, "Turtle");
Re: How to pun a URI?
Posted by Steve Vestal <st...@adventiumlabs.com>.
I searched a bit for a way to declare a HasKey axiom. Does this mean that is
a futile exercise?
On 10/24/2021 6:57 AM, Lorenz Buehmann wrote:
> yeah, punning is a new feature of OWL 2, Jena does only support OWL 1 and
> some parts of OWL 2. Whether there is a workaround or room for a feature
> request, Dave Reynolds knows better for sure.
>
> On 24.10.21 13:48, Martynas Jusevičius wrote:
>> Could this be the reason?
>> “ OWL DL includes all OWL language constructs with restrictions such as
>> type separation (a class can not also be an individual or property, a
>> property can not also be an individual or class).”
>>
>> https://www.w3.org/TR/owl-guide/
>>
>> On Sun, 24 Oct 2021 at 13.43, Steve Vestal <st...@adventiumlabs.com>
>> 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. 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.
>>>
>>> On 10/20/2021 5:30 AM, Lorenz Buehmann wrote:
>>>> OntModel m = ModelFactory.createOntologyModel();
>>>> String uri = "http://ex.org/A";
>>>> OntClass cls = m.createClass(uri);
>>>> cls.createIndividual(uri);
>>>> m.write(System.out, "Turtle");
Re: Re: How to pun a URI?
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
yeah, punning is a new feature of OWL 2, Jena does only support OWL 1
and some parts of OWL 2. Whether there is a workaround or room for a
feature request, Dave Reynolds knows better for sure.
On 24.10.21 13:48, Martynas Jusevičius wrote:
> Could this be the reason?
> “ OWL DL includes all OWL language constructs with restrictions such as
> type separation (a class can not also be an individual or property, a
> property can not also be an individual or class).”
>
> https://www.w3.org/TR/owl-guide/
>
> On Sun, 24 Oct 2021 at 13.43, Steve Vestal <st...@adventiumlabs.com>
> 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. 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.
>>
>> On 10/20/2021 5:30 AM, Lorenz Buehmann wrote:
>>> OntModel m = ModelFactory.createOntologyModel();
>>> String uri = "http://ex.org/A";
>>> OntClass cls = m.createClass(uri);
>>> cls.createIndividual(uri);
>>> m.write(System.out, "Turtle");
Re: How to pun a URI?
Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Could this be the reason?
“ OWL DL includes all OWL language constructs with restrictions such as
type separation (a class can not also be an individual or property, a
property can not also be an individual or class).”
https://www.w3.org/TR/owl-guide/
On Sun, 24 Oct 2021 at 13.43, Steve Vestal <st...@adventiumlabs.com>
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. 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.
>
> On 10/20/2021 5:30 AM, Lorenz Buehmann wrote:
> > OntModel m = ModelFactory.createOntologyModel();
> > String uri = "http://ex.org/A";
> > OntClass cls = m.createClass(uri);
> > cls.createIndividual(uri);
> > m.write(System.out, "Turtle");
>
Re: How to pun a URI?
Posted by Steve Vestal <st...@adventiumlabs.com>.
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
Re: How to pun a URI?
Posted by Steve Vestal <st...@adventiumlabs.com>.
Oops, my mistake, I left it hard-coded rather than parameterizing it
correctly. This does work for me.
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
Re: How to pun a URI?
Posted by Dave Reynolds <da...@gmail.com>.
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
Re: How to pun a URI?
Posted by Steve Vestal <st...@adventiumlabs.com>.
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;
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
Re: Re: How to pun a URI?
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
Openllet is just a fork of Pellet, which in fact does support full OWL 2
DL, thus, allows punning.
On 24.10.21 20:28, 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
Re: How to pun a URI?
Posted by Dave Reynolds <da...@gmail.com>.
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
Re: How to pun a URI?
Posted by Steve Vestal <st...@adventiumlabs.com>.
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. 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.
On 10/20/2021 5:30 AM, Lorenz Buehmann wrote:
> OntModel m = ModelFactory.createOntologyModel();
> String uri = "http://ex.org/A";
> OntClass cls = m.createClass(uri);
> cls.createIndividual(uri);
> m.write(System.out, "Turtle");
Re: How to pun a URI?
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
Works for me as expected when doing
OntModel m = ModelFactory.createOntologyModel();
String uri = "http://ex.org/A";
OntClass cls = m.createClass(uri);
cls.createIndividual(uri);
m.write(System.out, "Turtle");Result is @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 .
On 20.10.21 11:39, Steve Vestal wrote:
> I am creating an OntClass but also want to pun that IRI, so that I
> have an Individual with that same IRI that can be a member of a
> class. Here is an example of doing that in OFN (a class that contains
> itself, sort of but not really as I understand it), which works in
> Protege.
>
> Declaration( Class( :myClass ) )
> ClassAssertion( :myClass :myClass )
>
> When I try the following two approaches, I get an
> org.apache.jena.ontology.ConversionException. How do I make the above
> declarations using the Jena APIs?
>
> // punnedClass is an OntClass to be punned
> // containingClass is an OntClass to contain the Individual
> interpretation of punnedClass
> model.createIndividual(punnedClass.getURI(), containingClass);
> containingClass.createIndividual(punnedClass.getURI());