Dave, Thank you, works like a charm. It's like, we can do the hard stuff, certainly we can do the easy stuff. David
---------------------------------------- From: "Dave Reynolds" <[email protected]> Sent: Wednesday, March 09, 2011 1:02 PM To: [email protected] Subject: Re: asserted properties 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
