On Thu, Mar 14, 2013 at 9:59 AM, David Jordan <[email protected]> wrote:
> There is an individual in another organization of my company that is 
> struggling to get something working in Jena. I have advised him several times 
> to post his issue to this group, but he won’t. He is trying to have an 
> instance get dynamically associated with a subclass. I don’t have the time 
> bandwidth to figure this out for him because I am busy with my own Jena 
> evaluation work due in about a week. His issue deals with how/whether Jena 
> does inferencing on the fly. He is not getting the results he expects. Below 
> is his sample ontology and also the Jena Java code. His challenge/question is 
> in the comments at the very end of the code.
>
> This is part of a multi-organizational evaluation of Jena, considering its 
> adoption. So getting this resolved will be helpful to Jena.
> I am off on vacation next week, so it would be good if a solution could be 
> provided by tomorrow.
> I hope this is possible in Jena, I was surprised it was not working.

I think the main problem here is that Individuals (and more generally,
Resources) is that there's more than one model in play, and asking for
properties of an individual *through the individual* is asking for the
statements *in the model that the individual came from*.  So, in the
code that was provided,  we have something like

Model m1 = ..., m2 = ...;
Individual x = m.createIndividual( ... ); // x is an individual for model m1
m2.add( x, prop, obj ) ; // add a triple to m2 whose subject is the
resource that x represents

x.listProperties won't contain [prop, obj] because x is associated
with m1, but [x, prop, obj] is in m2.

The solution that makes the fewest changes to that code is to use just
one model,  an OntModel with inferencing. In this case, that means:

       OntModel m = ModelFactory.createOntologyModel(
OntModelSpec.OWL_DL_MEM_RULE_INF );

and get rid the models named "model" and "data". If you actually need
to have multiple models, do all your querying through the model that
has inference.  That will mean having to do

  m.contains( x, RDF.type, motorcycle )

instead of

  x.hasRDFType( motorcycle )

when the model associated with x is not m.

//JT

-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Reply via email to