On 27/11/12 14:16, ashish nijhara wrote:
Thanks Dave. you gave me a really interesting information.
Is that the purpose of designing sub models really? that sub models will
typically represent static things?
Sub-models were motivated by the need to support OWL import processing.
With OWL you sometimes want to see the imports closure of an ontology -
the union of the statements in the ontology and statements in all of its
imported ontologies. Yet when you change the ontology you only want to
change the base ontology itself, not go round changing the content of
imported ontologies. When you write out the ontology you typically want
to only write out the base, not the imports closure.
OntModels make this convenience possible by keeping the base ontology
and the imports separated while letting you see their (dynamic) union.
They support a base model (where changes go, the model you see when you
do a write) plus a set of sub-models (which represent the imports).
So normally you make changes to the base model not the sub-models.
Normally, if you have inference enabled, then the reasoner sees the
changes to the base model as they are submitted so that it has the
option to do incremental reasoning.
Having said, that the sub-model mechanism is complete general so you can
use it how you wish. The sub-models don't need to be static, you are
free to update them and the changes will be reflected in the OntModel.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
So, my ontology set up is like the following:
parent ontology -> A.owl->only concepts
child ontology 1-> B.owl-> some new concepts+ some Named Individuals, this
imports A.owl
child ontology 2-> c.owl-> some new concepts+ some Named Individuals
[different than B.owl], this also imports A.owl
data.rdf -> only individuals created during runtime [this data.rdf needs to
be divided into further sub models based on what data is required]. So it
is a Tree of Graphs essentially.
I attached the reasoner on the Ontmodel of child ontology 1 and added
data.rdf as a subModel to the OntModel. This data.rdf can have further sub
models (models directly mapped to graphs in a database using SDB), so I
would need correct keys (uris) of these of the submodels (graphs).
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If Jena is primarily designed to work the other way, then my approach may
end up using more memory or?
If you thought of this in terms of ontology documents then you would
typically have a data.owl file containing your data which imported your
child ontology (and so your parent ontology).
So a typical way to do this with OntModels is the same, have your data
be the base model for the OntModel and have it import the ontologies,
which will then appear as sub-models.
However in your case you say you also want the data model itself to be
partitioned and it sounds like you want to update any of these partitions.
Sounds odd but if that's really what you need then so be it. From Jena's
point of view that's all fine. You are free to use sub-models how you
wish. There's not space penalty.
The only cost is there is no longer a single point of entry where you
are making changes so you will need to make sure you notify the reasoner
(with a rebind) when you want it to re-consult your changed sub-models.
Dave
Thanks,
Ashish
On Tue, Nov 27, 2012 at 1:21 AM, Dave Reynolds <[email protected]>wrote:
On 23/11/12 08:10, ashish nijhara wrote:
Hi All,
I have a problem statement as the following:
I have an OntModel which has only stored concepts with pre-defined
individuals or named individuals. There is a reasoner attached to it.
I have a sub model which needs to contain only the working data. No new
concepts can be added here.
final OntModelSpec spec = OntModelSpec.OWL_DL_MEM;
final OntModel ontModel = ModelFactory.**createOntologyModel(spec);
ontModel.read(<url>);
final Reasoner reasoner = PelletReasonerFactory.**
theInstance().create();
reasoner.bindSchema(ontModel);
final OntModel dataModel = ModelFactory.**createOntologyModel();
ontModel.addSubModel(**dataModel);
ontModel.prepare();
...........
...........
...........
Now when I create an individual, I would like to add this to the subModel.
To do this, I need to find correct Sub Model.
ontModel.listSubModels() will return all the submodels (there are more
than
one sub models to the ontModel).
How do I fetch my correct subModel that is the dataModel above? There is
no
method in Jena to get me a particular subModel or it there something I
need
to do more to achieve this.?
Seems like an odd arrangement. When you add statements to an OntModel the
additions go into the base model. So normal practice is to make the things
you don't want to change (like the ontology) the sub-models.
If you go round finding particular sub-models and adding directly to them
you will probably need to call rebind() on the OntModel to restart the
reasoner over the changed data.
If you really do want to use this sub-model arrangement they you will need
to keep an index of sub-models somewhere else. Jena itself is just treating
an OntModel as set of graphs, there's no associated label or annotation on
the graphs.
Dave