On Thu, May 16, 2013 at 2:36 PM, Ed Swing <[email protected]> wrote:
> While I see the difference in the code, the distinction is not at all 
> apparent between
>
> model2 = ModelFactory.createOntologyModel(model1.getSpecification(), model1);
>
> and
>
> model2 = ModelFactory.createOntologyModel( model1.getSpecification() ) :
> model2.add( model1.getBaseModel() );
>
> According to the Javadoc, the method createOntologyModel(OntModelSpec spec, 
> Model base) does the following: "Answer a new ontology model, constructed 
> according to the given ontology model specification, and starting with the 
> ontology data in the given model."
>
> So it creates a new ontology model, using the given ontology specification 
> (which is the same as the old ontology model, e.g., 
> OntModelSpec.OWL_DL_MEM_RULE_INF). It would start with the data from the 
> given model, so it should have the triples from the old model. In the second 
> case above, only the base triples from model1 are added initially, but since 
> they have the same inferencer, it should derive the same triples.

They'll have the same inferences, provided that the first OntModel
doesn't have any addition triples stored in a submodel or something
like that that the reasoner would see.  If it does, then the second
model doesn't have everything that the first one did.  Additionally,
if you make the first OntModel the base of the second one, you've
effectively got *two* reasoners running on the second model, and that
could cause some kind of performance problem.  I don't know whether
this would have any terrible effects or not.

I know that Jena's rule based reasoners can put things into a graph
that aren't RDF triples; maybe some of these that are generated by the
first model (which would be the base model of the second model) are
seen by the second model's reasoner, and this causes some bad thing to
happen.  (Complete speculation there;  I know nothing about what
Jena's reasoners are doing to check validity.)

You'll also want to be careful about how models are chained, too, for
storage purposes.  In the way you originally had it, if you add
something to either model (after creating both), you'll see it in the
other, too.  Is that what you're expecting?

> In any case, I don't understand why model1 would be valid and model2 invalid 
> if they have the same triples and same specification.

Aside from what I mentioned above (if the first model's reasoner is
adding some things to the graph that confuse the second model's
reasoner), I don't know either.  Do you get the same problem if the
second OntModel just has the same base graph?  I.e., something like

OntModel m1 = ModelFactory.createOntologyModel(
OntModelSpec.OWL_DL_MEM_RULE_INF );
OntModel m2 = ModelFactory.createOntologyModel( m1.getSpecification(),
m1.getBaseModel() );

?

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

Reply via email to