You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Scott Streit <sc...@scottstreit.com> on 2012/11/27 22:23:40 UTC

Trying to get an identifier for an entire statement

I am using solr as a store for Jena.  Works fine until I try reification.

I need a way to take a statement (SPO) and have an id for it.

Then I can use the id, for my reification.

Is there any way to store an id in a java Statement, or to get on from a
Statement?

In essence, I am looking for a surrogate key for a statement.

Thanks.


On Tue, Nov 27, 2012 at 10:45 AM, ashish nijhara
<ni...@gmail.com>wrote:

> Thanks Dave for the wonderful explanation. :)
>
> Much appreciated.
>
> Thanks,
> Ashish
>
> On Tue, Nov 27, 2012 at 11:28 PM, Dave Reynolds
> <da...@gmail.com>wrote:
>
> > The explanation of imports processing and the resulting trees of models
> is
> > well-described in the Ontology documentation.
> >
> > As I said to Ashish the sub-model system (which under the hood is
> > MultiUnion) is general purpose. You are free to change sub-models and
> those
> > changes are immediate reflected in the dynamic union. You are free to use
> > this mechanism how you wish.
> >
> > There is a distinguished member of the union where updates to the union
> > get sent. So *if* you had a single mutable model and a collection of
> > imported models then it would be sensible to make the mutable model the
> > base model. Hence my original comment to Ashish. That's not the same as
> > saying that you are constrained to *only* use sub-models that way.
> >
> > Dave
> >
> >
> > On 27/11/12 14:23, David Jordan wrote:
> >
> >> I had the same reaction. Is this described in the documentation? I have
> >> been away from Jena for about a year, but luckily it looks like I have
> >> finally gotten commitment to do some work with it again. I was not
> aware of
> >> this characteristic of sub models when I started playing around with
> them a
> >> year ago. I'll be doing another technical/performance evaluation, and
> >> things like this are very important to know.
> >>
> >> -----Original Message-----
> >> From: ashish nijhara [mailto:nijhara.ashish@gmail.**com<
> nijhara.ashish@gmail.com>
> >> ]
> >> Sent: Tuesday, November 27, 2012 9:16 AM
> >> To: users@jena.apache.org
> >> Subject: Re: Storing to the correct sub model
> >>
> >> 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?
> >>
> >> ------------------------------**------------------------------**
> >> ------------------------------**------------------------------**
> >> ------------------------------**------------------------------**
> >> ------------
> >> 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?
> >>
> >> Thanks,
> >> Ashish
> >>
> >>
> >>
> >> On Tue, Nov 27, 2012 at 1:21 AM, Dave Reynolds <
> dave.e.reynolds@gmail.com
> >> >**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
> >>>
> >>>
> >>>
> >>
> >
>



-- 
"If you are lucky enough to have lived in Paris as a young man, then
wherever you go for the rest of your life, it stays with you, for Paris is
a moveable feast." -  Ernest Hemingway

www.scottstreit.com

Re: Re: Trying to get an identifier for an entire statement

Posted by Chris Dollin <ch...@epimorphics.com>.
On Wednesday, November 28, 2012 07:38:41 AM Scott Streit wrote:
 
> When a extended a statement to an ExtendedStatement which I added a
> property of reificationId.  I then put the ExtendedStatement in the model.
> Unfortunately, when I pulled back the statement from the model, it was a
> statement, not an extended statement.

Yes.

In fact Models don't even store Statements; the Statements are stripped
down to Triples, whose S P O components are Nodes which are stripped-down
RDFNodes (Resources and Literals). The Triples are stored in the Graph that
the Model wraps.

When you ask for a Statement from a Model, eg using Model.listStatements 
or Resource.listProperties, the Model appeals to the Graph to find the appropriate
Triples and then reconstructs a corresponding Statement.

[There's a cache, but of course things fall out of caches.]

This indirection allows us to have Resource objects with lots of useful methods
that rely on knowing what Model the resource is associated with while
having the internal Graph/Node implementation be much simpler and
easier to reimplement.

> I could use a way to uniquely identity a Jena Statement.

What are you actually trying to do, and how would this unique identifier help?

[Note that .equals() and .hashCode() are define on Statement[Impl]s, and
 are Model-independant, so you can have Statements as set elements and
 keys of maps just fine.]

Chris
 
-- 
"It is seldom good news."      ~Crystal Ball~, /The Tough Guide to Fantasyland/

Epimorphics Ltd, http://www.epimorphics.com
Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20 6PT
Epimorphics Ltd. is a limited company registered in England (number 7016688)


Re: Trying to get an identifier for an entire statement

Posted by Scott Streit <sc...@scottstreit.com>.
Chris,

When a extended a statement to an ExtendedStatement which I added a
property of reificationId.  I then put the ExtendedStatement in the model.
Unfortunately, when I pulled back the statement from the model, it was a
statement, not an extended statement.

I could use a way to uniquely identity a Jena Statement.

Any ideas?

Scott


On Wed, Nov 28, 2012 at 5:45 AM, Chris Dollin
<ch...@epimorphics.com>wrote:

> On Tuesday, November 27, 2012 04:23:40 PM Scott Streit wrote:
> > I am using solr as a store for Jena.  Works fine until I try reification.
> >
> > I need a way to take a statement (SPO) and have an id for it.
>
> Making one up isn't enough? Are you hoping to find specific
> Statement [objects] from some definitive handle?
>
> [I don't speak solr but I do speak Jena.]
>
> > Then I can use the id, for my reification.
> >
> > Is there any way to store an id in a java Statement, or to get on from a
> > Statement?
>
> No (assuming "java Statement" means "Jena Statement"). Statements
> don't have built-in identifiers.
>
> > In essence, I am looking for a surrogate key for a statement.
>
> You could toString() the statement, or concatenate with suitable
> punctuation the toString()s of the S P and O, or hash the S P and O
> with a suitable hashing method.
>
> It depends on what you're hoping to achieve with reification.
>
> Chris
>
> --
> "I don't want to know what the Structuralists think! I want     /Archer's
> Goon/
>  to know what YOU think!"
>
> Epimorphics Ltd, http://www.epimorphics.com
> Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20
> 6PT
> Epimorphics Ltd. is a limited company registered in England (number
> 7016688)
>
>


-- 
"If you are lucky enough to have lived in Paris as a young man, then
wherever you go for the rest of your life, it stays with you, for Paris is
a moveable feast." -  Ernest Hemingway

www.scottstreit.com

Re: Trying to get an identifier for an entire statement

Posted by Chris Dollin <ch...@epimorphics.com>.
On Tuesday, November 27, 2012 04:23:40 PM Scott Streit wrote:
> I am using solr as a store for Jena.  Works fine until I try reification.
> 
> I need a way to take a statement (SPO) and have an id for it.

Making one up isn't enough? Are you hoping to find specific
Statement [objects] from some definitive handle?

[I don't speak solr but I do speak Jena.]

> Then I can use the id, for my reification.
> 
> Is there any way to store an id in a java Statement, or to get on from a
> Statement?

No (assuming "java Statement" means "Jena Statement"). Statements
don't have built-in identifiers.

> In essence, I am looking for a surrogate key for a statement.

You could toString() the statement, or concatenate with suitable
punctuation the toString()s of the S P and O, or hash the S P and O
with a suitable hashing method.

It depends on what you're hoping to achieve with reification.

Chris

-- 
"I don't want to know what the Structuralists think! I want     /Archer's Goon/
 to know what YOU think!"

Epimorphics Ltd, http://www.epimorphics.com
Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20 6PT
Epimorphics Ltd. is a limited company registered in England (number 7016688)