You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by David Makovoz <da...@impact-computing.com> on 2011/03/09 18:25:03 UTC

asserted properties

I need to get asserted, and only asserted, properties for an individual.
E.g. the following                          Individual individual = ...;    
                  StmtIterator objectProperties = 
individual.listProperties();returns all properties, asserted and inferred. 

I can probably iterate over all predicates ontProp# of objectProperties 
above and test for each pair (ontProp1, ontProp2) whether one of them has 
the other as its subproperty, i.e.           
ontProp1.hasSubProperty(ontProp2, false)and if it does, I'll reject it 
(ontProp1 in this case).But it looks a little messy. 
Is there a clean way to do it?
Thank you, 

David Makovoz

 

Re: asserted properties

Posted by Dave Reynolds <da...@gmail.com>.
On Wed, 2011-03-09 at 12:25 -0500, David Makovoz wrote: 
> I need to get asserted, and only asserted, properties for an individual.
> E.g. the following                          Individual individual = ...;    
>                   StmtIterator objectProperties = 
> individual.listProperties();returns all properties, asserted and inferred. 
> 
> I can probably iterate over all predicates ontProp# of objectProperties 
> above and test for each pair (ontProp1, ontProp2) whether one of them has 
> the other as its subproperty, i.e.           
> ontProp1.hasSubProperty(ontProp2, false)and if it does, I'll reject it 
> (ontProp1 in this case).But it looks a little messy. 
> Is there a clean way to do it?

I assume you have some OntModel with a OntModelSpec that includes
inference. 

The cleanest solution is to query the raw or base model. Either just use
getBaseModel or, if you want to be able to access the base as an
OntModel instead of a vanilla Model, then do something like:

   OntModel asserted = ModelFactory.createOntologyModel(
                            OntModelSpec.OWL_MEM, inf.getBaseModel());

Whether you want "raw" or "base" depends on whether you want to see any
imports.

The "baseModel" of an OntModel is the bit without imports, the bit that
gets updated if you add statements to it.

The "rawModel" of an InfModel is the raw data, with no inference
applied.

Since OntModel extends InfModel is supports both "base" and "raw".

Dave