You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Jos Lehmann <Jo...@bauhaus-luftfahrt.net> on 2017/01/12 15:30:14 UTC
Listing all individuals of an ontology, including those defined in
the ontology as individuals of classes coming from import ontology
Hi there
SITUATION
-- A
I am working with ontology L (denoted as Ontology_input_file in Code below) with URI:
http://www.b-l.net/ontologies/2016/L_Ontology.owl#
-- B
This ontology imports an ontology PS with URI:
http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
Note that I have added a number of indivuduals to L, as individuals of classes coming from import ontology PS. I.e. these individuals have L's URI but are of types defined in PS.
PROBLEM
In order to get the complete list of individuals I use the following code:
OntModel model = ModelFactory.createOntologyModel();
model.read(Ontology_input_file);
ExtendedIterator individuals = model.listIndividuals();
while (individuals.hasNext()) {
Individual thisIndividual = (Individual) individuals.next();
System.out.println(thisIndividual.toString())
}
With this code I only get individuals defined in L as instances of classes that have L's URI.
How do I get the entire list of individuals, including those described in B above?
Thanks, Jos
Re: AW: AW: Listing all individuals of an ontology, including those
defined in the ontology as individuals of classes coming from import ontology
Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
I do not understand. I meant that the URIs can't be resolved, you can
try it in the browser or using curl, wget etc.
You have to use the URIs resp. URLs where your ontologies exist, I don't
know where this is in your environment.
> Hi Lorenz
>
> I see -- how should the URI be given?
>
> Thanks, Jos
>
>
> -----Urspr�ngliche Nachricht-----
> Von: Lorenz B. [mailto:buehmann@informatik.uni-leipzig.de]
> Gesendet: Dienstag, 17. Januar 2017 13:57
> An: users@jena.apache.org
> Betreff: Re: AW: Listing all individuals of an ontology, including those defined in the ontology as individuals of classes coming from import ontology
>
> It does but not if the URI are given as you've shown. Both URIs can't be resolved to ontology files.
>> Hi Andreas,
>>
>> Yes, I had not read in the import ontology. I thought that would be automatic.
>>
>> Thanks, Jos
>>
>>
>> -----Urspr�ngliche Nachricht-----
>> Von: Andreas Prie� [mailto:ap@metaphysis.net]
>> Gesendet: Samstag, 14. Januar 2017 19:47
>> An: users@jena.apache.org
>> Betreff: Re: Listing all individuals of an ontology, including those
>> defined in the ontology as individuals of classes coming from import
>> ontology
>>
>> Hi,
>>
>> you probably should check explicitly whether the second ontology was actually imported.
>>
>> Have a look at
>>
>> OntModel.hasLoadedImport(String uri)
>> or
>> OntModel.listSubModels(boolean withImports)
>>
>> I suppose there is a problem importing the second ontology since the URL seems not to be resolvable.
>>
>>
>> ~ Andreas
>>
>>
>> On 12.01.2017 16:30, Jos Lehmann wrote:
>>> Hi there
>>>
>>> SITUATION
>>>
>>> -- A
>>>
>>> I am working with ontology L (denoted as Ontology_input_file in Code below) with URI:
>>> http://www.b-l.net/ontologies/2016/L_Ontology.owl#
>>>
>>>
>>> -- B
>>>
>>> This ontology imports an ontology PS with URI:
>>> http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
>>>
>>> Note that I have added a number of indivuduals to L, as individuals of classes coming from import ontology PS. I.e. these individuals have L's URI but are of types defined in PS.
>>>
>>> PROBLEM
>>>
>>> In order to get the complete list of individuals I use the following code:
>>>
>>> OntModel model = ModelFactory.createOntologyModel();
>>> model.read(Ontology_input_file);
>>>
>>> ExtendedIterator individuals = model.listIndividuals(); while
>>> (individuals.hasNext()) { Individual thisIndividual = (Individual)
>>> individuals.next();
>>> System.out.println(thisIndividual.toString())
>>> }
>>>
>>>
>>> With this code I only get individuals defined in L as instances of classes that have L's URI.
>>>
>>> How do I get the entire list of individuals, including those described in B above?
>>>
>>>
>>> Thanks, Jos
>>
> --
> Lorenz B�hmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>
>
--
Lorenz B�hmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
AW: AW: Listing all individuals of an ontology, including those
defined in the ontology as individuals of classes coming from import ontology
Posted by Jos Lehmann <Jo...@bauhaus-luftfahrt.net>.
Hi Lorenz
I see -- how should the URI be given?
Thanks, Jos
-----Ursprüngliche Nachricht-----
Von: Lorenz B. [mailto:buehmann@informatik.uni-leipzig.de]
Gesendet: Dienstag, 17. Januar 2017 13:57
An: users@jena.apache.org
Betreff: Re: AW: Listing all individuals of an ontology, including those defined in the ontology as individuals of classes coming from import ontology
It does but not if the URI are given as you've shown. Both URIs can't be resolved to ontology files.
> Hi Andreas,
>
> Yes, I had not read in the import ontology. I thought that would be automatic.
>
> Thanks, Jos
>
>
> -----Ursprüngliche Nachricht-----
> Von: Andreas Prieß [mailto:ap@metaphysis.net]
> Gesendet: Samstag, 14. Januar 2017 19:47
> An: users@jena.apache.org
> Betreff: Re: Listing all individuals of an ontology, including those
> defined in the ontology as individuals of classes coming from import
> ontology
>
> Hi,
>
> you probably should check explicitly whether the second ontology was actually imported.
>
> Have a look at
>
> OntModel.hasLoadedImport(String uri)
> or
> OntModel.listSubModels(boolean withImports)
>
> I suppose there is a problem importing the second ontology since the URL seems not to be resolvable.
>
>
> ~ Andreas
>
>
> On 12.01.2017 16:30, Jos Lehmann wrote:
>> Hi there
>>
>> SITUATION
>>
>> -- A
>>
>> I am working with ontology L (denoted as Ontology_input_file in Code below) with URI:
>> http://www.b-l.net/ontologies/2016/L_Ontology.owl#
>>
>>
>> -- B
>>
>> This ontology imports an ontology PS with URI:
>> http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
>>
>> Note that I have added a number of indivuduals to L, as individuals of classes coming from import ontology PS. I.e. these individuals have L's URI but are of types defined in PS.
>>
>> PROBLEM
>>
>> In order to get the complete list of individuals I use the following code:
>>
>> OntModel model = ModelFactory.createOntologyModel();
>> model.read(Ontology_input_file);
>>
>> ExtendedIterator individuals = model.listIndividuals(); while
>> (individuals.hasNext()) { Individual thisIndividual = (Individual)
>> individuals.next();
>> System.out.println(thisIndividual.toString())
>> }
>>
>>
>> With this code I only get individuals defined in L as instances of classes that have L's URI.
>>
>> How do I get the entire list of individuals, including those described in B above?
>>
>>
>> Thanks, Jos
>
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
Re: AW: Listing all individuals of an ontology, including those
defined in the ontology as individuals of classes coming from import ontology
Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
It does but not if the URI are given as you've shown. Both URIs can't be
resolved to ontology files.
> Hi Andreas,
>
> Yes, I had not read in the import ontology. I thought that would be automatic.
>
> Thanks, Jos
>
>
> -----Urspr�ngliche Nachricht-----
> Von: Andreas Prie� [mailto:ap@metaphysis.net]
> Gesendet: Samstag, 14. Januar 2017 19:47
> An: users@jena.apache.org
> Betreff: Re: Listing all individuals of an ontology, including those defined in the ontology as individuals of classes coming from import ontology
>
> Hi,
>
> you probably should check explicitly whether the second ontology was actually imported.
>
> Have a look at
>
> OntModel.hasLoadedImport(String uri)
> or
> OntModel.listSubModels(boolean withImports)
>
> I suppose there is a problem importing the second ontology since the URL seems not to be resolvable.
>
>
> ~ Andreas
>
>
> On 12.01.2017 16:30, Jos Lehmann wrote:
>> Hi there
>>
>> SITUATION
>>
>> -- A
>>
>> I am working with ontology L (denoted as Ontology_input_file in Code below) with URI:
>> http://www.b-l.net/ontologies/2016/L_Ontology.owl#
>>
>>
>> -- B
>>
>> This ontology imports an ontology PS with URI:
>> http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
>>
>> Note that I have added a number of indivuduals to L, as individuals of classes coming from import ontology PS. I.e. these individuals have L's URI but are of types defined in PS.
>>
>> PROBLEM
>>
>> In order to get the complete list of individuals I use the following code:
>>
>> OntModel model = ModelFactory.createOntologyModel();
>> model.read(Ontology_input_file);
>>
>> ExtendedIterator individuals = model.listIndividuals();
>> while (individuals.hasNext()) {
>> Individual thisIndividual = (Individual) individuals.next();
>> System.out.println(thisIndividual.toString())
>> }
>>
>>
>> With this code I only get individuals defined in L as instances of classes that have L's URI.
>>
>> How do I get the entire list of individuals, including those described in B above?
>>
>>
>> Thanks, Jos
>
>
--
Lorenz B�hmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
AW: Listing all individuals of an ontology, including those defined
in the ontology as individuals of classes coming from import ontology
Posted by Jos Lehmann <Jo...@bauhaus-luftfahrt.net>.
Hi Andreas,
Yes, I had not read in the import ontology. I thought that would be automatic.
Thanks, Jos
-----Ursprüngliche Nachricht-----
Von: Andreas Prieß [mailto:ap@metaphysis.net]
Gesendet: Samstag, 14. Januar 2017 19:47
An: users@jena.apache.org
Betreff: Re: Listing all individuals of an ontology, including those defined in the ontology as individuals of classes coming from import ontology
Hi,
you probably should check explicitly whether the second ontology was actually imported.
Have a look at
OntModel.hasLoadedImport(String uri)
or
OntModel.listSubModels(boolean withImports)
I suppose there is a problem importing the second ontology since the URL seems not to be resolvable.
~ Andreas
On 12.01.2017 16:30, Jos Lehmann wrote:
> Hi there
>
> SITUATION
>
> -- A
>
> I am working with ontology L (denoted as Ontology_input_file in Code below) with URI:
> http://www.b-l.net/ontologies/2016/L_Ontology.owl#
>
>
> -- B
>
> This ontology imports an ontology PS with URI:
> http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
>
> Note that I have added a number of indivuduals to L, as individuals of classes coming from import ontology PS. I.e. these individuals have L's URI but are of types defined in PS.
>
> PROBLEM
>
> In order to get the complete list of individuals I use the following code:
>
> OntModel model = ModelFactory.createOntologyModel();
> model.read(Ontology_input_file);
>
> ExtendedIterator individuals = model.listIndividuals();
> while (individuals.hasNext()) {
> Individual thisIndividual = (Individual) individuals.next();
> System.out.println(thisIndividual.toString())
> }
>
>
> With this code I only get individuals defined in L as instances of classes that have L's URI.
>
> How do I get the entire list of individuals, including those described in B above?
>
>
> Thanks, Jos
Re: Listing all individuals of an ontology, including those defined
in the ontology as individuals of classes coming from import ontology
Posted by Andreas Prieß <ap...@metaphysis.net>.
Hi,
you probably should check explicitly whether the second ontology was
actually imported.
Have a look at
OntModel.hasLoadedImport(String uri)
or
OntModel.listSubModels(boolean withImports)
I suppose there is a problem importing the second ontology since the URL
seems not to be resolvable.
~ Andreas
On 12.01.2017 16:30, Jos Lehmann wrote:
> Hi there
>
> SITUATION
>
> -- A
>
> I am working with ontology L (denoted as Ontology_input_file in Code below) with URI:
> http://www.b-l.net/ontologies/2016/L_Ontology.owl#
>
>
> -- B
>
> This ontology imports an ontology PS with URI:
> http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
>
> Note that I have added a number of indivuduals to L, as individuals of classes coming from import ontology PS. I.e. these individuals have L's URI but are of types defined in PS.
>
> PROBLEM
>
> In order to get the complete list of individuals I use the following code:
>
> OntModel model = ModelFactory.createOntologyModel();
> model.read(Ontology_input_file);
>
> ExtendedIterator individuals = model.listIndividuals();
> while (individuals.hasNext()) {
> Individual thisIndividual = (Individual) individuals.next();
> System.out.println(thisIndividual.toString())
> }
>
>
> With this code I only get individuals defined in L as instances of classes that have L's URI.
>
> How do I get the entire list of individuals, including those described in B above?
>
>
> Thanks, Jos