You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Benson Margulies <bi...@gmail.com> on 2010/12/11 00:14:09 UTC

Reasoners, Datasets, Models

I want to make an InfModel that puts an inference engine on top of a
TDB dataset so that inference happens over the set. If this isn't a
nutty idea altogether, is there any way to do this without using the
assembler? And if not I fear I'll be asking for some assistance.

Re: Reasoners, Datasets, Models

Posted by Ian Dickinson <ia...@epimorphics.com>.
On 13/12/10 16:34, Benson Margulies wrote:
> So, in practical terms, can I call 'read' on the OntModel that is
> constructed over the UNION_GRAPH to get the rules into its clutches?
Yes. Though I would say "... to get the triples from the ontology into
the clutches of the rules", since the rules themselves are embedded into
the choice of reasoner.

Ian


-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
              Portishead, Bristol BS20 6PT, UK


Re: Reasoners, Datasets, Models

Posted by Benson Margulies <bi...@gmail.com>.
So, in practical terms, can I call 'read' on the OntModel that is
constructed over the UNION_GRAPH to get the rules into its clutches?



On Mon, Dec 13, 2010 at 11:32 AM, Ian Dickinson <ia...@epimorphics.com> wrote:
> On 13/12/10 16:16, Benson Margulies wrote:
>> Meanwhile, is there any advantage of reading the ontology tuples
>> themselves into memory instead of into TDB?
> Yes, for sure, if you're using the inference engine. The reasoners make
> many, many checks into the model of the form "is triple <t>
> present/absent?". If that check goes to TDB, at best you're hitting the
> cache but at worst you'll be doing a disk operation. For a small model,
> if I understand it correctly, TDB will have everything cached. But for a
> larger model, you will likely pay a performance** penalty.
>
> Ian
>
> **
> http://www.reddit.com/r/programming/comments/90tge/hey_rprogramming_i_made_a_visualization_of_the/c0b1t0v
>
>
>
> --
> ____________________________________________________________
> Ian Dickinson                   Epimorphics Ltd, Bristol, UK
> mailto:ian@epimorphics.com        http://www.epimorphics.com
> cell: +44-7786-850536              landline: +44-1275-399069
> ------------------------------------------------------------
> Epimorphics Ltd.  is a limited company registered in England
> (no. 7016688). Registered address: Court Lodge, 105 High St,
>              Portishead, Bristol BS20 6PT, UK
>
>

Re: Reasoners, Datasets, Models

Posted by Ian Dickinson <ia...@epimorphics.com>.
On 13/12/10 16:16, Benson Margulies wrote:
> Meanwhile, is there any advantage of reading the ontology tuples
> themselves into memory instead of into TDB?
Yes, for sure, if you're using the inference engine. The reasoners make
many, many checks into the model of the form "is triple <t>
present/absent?". If that check goes to TDB, at best you're hitting the
cache but at worst you'll be doing a disk operation. For a small model,
if I understand it correctly, TDB will have everything cached. But for a
larger model, you will likely pay a performance** penalty.

Ian

**
http://www.reddit.com/r/programming/comments/90tge/hey_rprogramming_i_made_a_visualization_of_the/c0b1t0v



-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
              Portishead, Bristol BS20 6PT, UK


Re: Reasoners, Datasets, Models

Posted by Benson Margulies <bi...@gmail.com>.
Aha. I get it. a Pull Request is just a tricked-out way to tell me to
regular git tools to do a merge.

I make you a collaborator. Stay clear of the resistance.


On Mon, Dec 13, 2010 at 11:16 AM, Benson Margulies
<bi...@gmail.com> wrote:
> Yea, I read that. It says that you gotta make the pull request. Stand by.
>
>
> Meanwhile, is there any advantage of reading the ontology tuples
> themselves into memory instead of into TDB?
>
>
> On Mon, Dec 13, 2010 at 10:34 AM, Ian Dickinson <ia...@epimorphics.com> wrote:
>> On 13/12/10 15:32, Ian Dickinson wrote:
>>> On 13/12/10 14:40, Benson Margulies wrote:
>>>> I'm a litttle new to this.
>>> Yeah, me too.
>> I found this helpful, btw:
>>
>> http://help.github.com/pull-requests/
>>
>> Ian
>>
>>
>> --
>> ____________________________________________________________
>> Ian Dickinson                   Epimorphics Ltd, Bristol, UK
>> mailto:ian@epimorphics.com        http://www.epimorphics.com
>> cell: +44-7786-850536              landline: +44-1275-399069
>> ------------------------------------------------------------
>> Epimorphics Ltd.  is a limited company registered in England
>> (no. 7016688). Registered address: Court Lodge, 105 High St,
>>              Portishead, Bristol BS20 6PT, UK
>>
>>
>

Re: Reasoners, Datasets, Models

Posted by Benson Margulies <bi...@gmail.com>.
Yea, I read that. It says that you gotta make the pull request. Stand by.


Meanwhile, is there any advantage of reading the ontology tuples
themselves into memory instead of into TDB?


On Mon, Dec 13, 2010 at 10:34 AM, Ian Dickinson <ia...@epimorphics.com> wrote:
> On 13/12/10 15:32, Ian Dickinson wrote:
>> On 13/12/10 14:40, Benson Margulies wrote:
>>> I'm a litttle new to this.
>> Yeah, me too.
> I found this helpful, btw:
>
> http://help.github.com/pull-requests/
>
> Ian
>
>
> --
> ____________________________________________________________
> Ian Dickinson                   Epimorphics Ltd, Bristol, UK
> mailto:ian@epimorphics.com        http://www.epimorphics.com
> cell: +44-7786-850536              landline: +44-1275-399069
> ------------------------------------------------------------
> Epimorphics Ltd.  is a limited company registered in England
> (no. 7016688). Registered address: Court Lodge, 105 High St,
>              Portishead, Bristol BS20 6PT, UK
>
>

Re: Reasoners, Datasets, Models

Posted by Ian Dickinson <ia...@epimorphics.com>.
On 13/12/10 15:32, Ian Dickinson wrote:
> On 13/12/10 14:40, Benson Margulies wrote:
>> I'm a litttle new to this.
> Yeah, me too.
I found this helpful, btw:

http://help.github.com/pull-requests/

Ian


-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
              Portishead, Bristol BS20 6PT, UK


Re: Reasoners, Datasets, Models

Posted by Ian Dickinson <ia...@epimorphics.com>.
Hi Benson,

On 13/12/10 14:40, Benson Margulies wrote:
> Can you do something on git hub to push your version back towards my
> version? 
No, because your repository is only write enabled for a certain group
(which, by default, is just the repo owner)

> Or can I pull your changes as things are? 
That's the norm. I can facilitate the process by sending you a pull
request, which I've done

> I'm a litttle new to this.
Yeah, me too.

Ian

-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
              Portishead, Bristol BS20 6PT, UK


Re: Reasoners, Datasets, Models

Posted by Benson Margulies <bi...@gmail.com>.
Ian,

Can you do something on git hub to push your version back towards my
version? Or can I pull your changes as things are? I'm a litttle new
to this.

--benson


On Mon, Dec 13, 2010 at 8:43 AM, Ian Dickinson <ia...@epimorphics.com> wrote:
> Hi Benson,
> On 11/12/10 01:02, Benson Margulies wrote:
>> Note that 'baseModel' is a MODEL, not a Dataset. I want to query over
>> all the graphs (as I can by passing a TDB dataset rather than a model
>> into the query universe.) Even if I set TDB.symUnionDefaultGraph,
>> passing the default model from the TDB doesn't work.
> I updated your example and pushed the changes to github:
>
> https://github.com/ephemerian/jena-tdb-ont-example
>
> I made two main changes:
>
> * I removed the JenaStore class. As far as I could tell, most of the
> responsibilities of this class for managing tdb files are duplicates of
> existing command line tools. In a general application, there might well
> be a need for a proxy- or decorator-pattern wrapper, but for a simple
> illustrative example the additional complexity is, I believe, not
> helpful. So I've moved responsibility for loading the named graphs in
> the store into src/main/script/init-demo.
>
> * I simplified the code to create an ontology inference model from the
> underlying TDB store. Note that the code could be simplified even more
> if you didn't use inference at this stage, since
> QueryExecutionFactory.create() can take a Dataset as well as a Model. In
> general, inference will work much better against in-memory models: using
> inference directly over a disk-based store is a pattern that's only
> likely to work efficiently for quite small models. If you think that
> you're going to need to work with large models and inference, we can
> give you advice on possible options.
>
> Ian
>
>
> --
> ____________________________________________________________
> Ian Dickinson                   Epimorphics Ltd, Bristol, UK
> mailto:ian@epimorphics.com        http://www.epimorphics.com
> cell: +44-7786-850536              landline: +44-1275-399069
> ------------------------------------------------------------
> Epimorphics Ltd.  is a limited company registered in England
> (no. 7016688). Registered address: Court Lodge, 105 High St,
>              Portishead, Bristol BS20 6PT, UK
>
>

Re: Reasoners, Datasets, Models

Posted by Benson Margulies <bi...@gmail.com>.
Thanks. JenaStore was an artifact of my larger code base where I was
thinking about also support Mulgara.

I am all electronic ears for your advice about inference; I think that
on a small scale I don't really need it, and on a large scale, later,
I'll need the advice.

On Mon, Dec 13, 2010 at 8:43 AM, Ian Dickinson <ia...@epimorphics.com> wrote:
> Hi Benson,
> On 11/12/10 01:02, Benson Margulies wrote:
>> Note that 'baseModel' is a MODEL, not a Dataset. I want to query over
>> all the graphs (as I can by passing a TDB dataset rather than a model
>> into the query universe.) Even if I set TDB.symUnionDefaultGraph,
>> passing the default model from the TDB doesn't work.
> I updated your example and pushed the changes to github:
>
> https://github.com/ephemerian/jena-tdb-ont-example
>
> I made two main changes:
>
> * I removed the JenaStore class. As far as I could tell, most of the
> responsibilities of this class for managing tdb files are duplicates of
> existing command line tools. In a general application, there might well
> be a need for a proxy- or decorator-pattern wrapper, but for a simple
> illustrative example the additional complexity is, I believe, not
> helpful. So I've moved responsibility for loading the named graphs in
> the store into src/main/script/init-demo.
>
> * I simplified the code to create an ontology inference model from the
> underlying TDB store. Note that the code could be simplified even more
> if you didn't use inference at this stage, since
> QueryExecutionFactory.create() can take a Dataset as well as a Model. In
> general, inference will work much better against in-memory models: using
> inference directly over a disk-based store is a pattern that's only
> likely to work efficiently for quite small models. If you think that
> you're going to need to work with large models and inference, we can
> give you advice on possible options.
>
> Ian
>
>
> --
> ____________________________________________________________
> Ian Dickinson                   Epimorphics Ltd, Bristol, UK
> mailto:ian@epimorphics.com        http://www.epimorphics.com
> cell: +44-7786-850536              landline: +44-1275-399069
> ------------------------------------------------------------
> Epimorphics Ltd.  is a limited company registered in England
> (no. 7016688). Registered address: Court Lodge, 105 High St,
>              Portishead, Bristol BS20 6PT, UK
>
>

Re: Reasoners, Datasets, Models

Posted by Ian Dickinson <ia...@epimorphics.com>.
Hi Benson,
On 11/12/10 01:02, Benson Margulies wrote:
> Note that 'baseModel' is a MODEL, not a Dataset. I want to query over
> all the graphs (as I can by passing a TDB dataset rather than a model
> into the query universe.) Even if I set TDB.symUnionDefaultGraph,
> passing the default model from the TDB doesn't work.
I updated your example and pushed the changes to github:

https://github.com/ephemerian/jena-tdb-ont-example

I made two main changes:

* I removed the JenaStore class. As far as I could tell, most of the
responsibilities of this class for managing tdb files are duplicates of
existing command line tools. In a general application, there might well
be a need for a proxy- or decorator-pattern wrapper, but for a simple
illustrative example the additional complexity is, I believe, not
helpful. So I've moved responsibility for loading the named graphs in
the store into src/main/script/init-demo.

* I simplified the code to create an ontology inference model from the
underlying TDB store. Note that the code could be simplified even more
if you didn't use inference at this stage, since
QueryExecutionFactory.create() can take a Dataset as well as a Model. In
general, inference will work much better against in-memory models: using
inference directly over a disk-based store is a pattern that's only
likely to work efficiently for quite small models. If you think that
you're going to need to work with large models and inference, we can
give you advice on possible options.

Ian


-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
              Portishead, Bristol BS20 6PT, UK


Re: Reasoners, Datasets, Models

Posted by Benson Margulies <bi...@gmail.com>.
On Fri, Dec 10, 2010 at 7:26 PM, Ian Dickinson <ia...@epimorphics.com> wrote:
> On 10/12/10 23:14, Benson Margulies wrote:
>>
>> I want to make an InfModel that puts an inference engine on top of a
>> TDB dataset so that inference happens over the set. If this isn't a
>> nutty idea altogether,
>
> Not nutty, but performance may not be great since the inference engine makes
> many queries into the model, and going to disk is slow ...

Another possibility. My main interest in inference is some sameAs
tuples that get added to the pile to represent coreference. Might I be
better off running a query that returns an initial collection of
individuals, and then running my own query to follow the sameAs (or
any other) links that I care about?


>
>> is there any way to do this without using the
>> assembler?
>
> Yes.
>
> Model baseModel = ... yourTDBModel ...;
> OntModel infModel = ModelFactory.createOntologyModel(
>        OntModelSpec.OWL_MEM_MICRO_RULE_INF,    // deductions in memory
>        baseModel                               // axioms in TDB


Note that 'baseModel' is a MODEL, not a Dataset. I want to query over
all the graphs (as I can by passing a TDB dataset rather than a model
into the query universe.) Even if I set TDB.symUnionDefaultGraph,
passing the default model from the TDB doesn't work.

I tried the above using the TDB's default graph, got no results. I
even tried to crib the code that implements that:

        Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
        DatasetGraphTDB ds = dsGraph.duplicate();
        ds.setEffectiveDefaultGraph(new GraphNamedTDB(ds, Quad.unionGraph));
        InfGraph graph =
reasoner.bindSchema(schemaModel.getGraph()).bind(ds.getDefaultGraph());
        InfModel infModel = new InfModelImpl(graph);

What's frustrating is that even very simple queries return no result.
I haven't even got as far as trying any actual inference.



> );
>
>
> Ian
>
> --
> ____________________________________________________________
> Ian Dickinson                   Epimorphics Ltd, Bristol, UK
> mailto:ian@epimorphics.com        http://www.epimorphics.com
> cell: +44-7786-850536              landline: +44-1275-399069
> ------------------------------------------------------------
> Epimorphics Ltd.  is a limited company registered in England
> (no. 7016688). Registered address: Court Lodge, 105 High St,
>              Portishead, Bristol BS20 6PT, UK
>
>

Re: Reasoners, Datasets, Models

Posted by Benson Margulies <bi...@gmail.com>.
I got basic queries to work by doing a less baroque variation on that
code for packaging up the union as a model. I think I'm off to the
races.

Re: Reasoners, Datasets, Models

Posted by Ian Dickinson <ia...@epimorphics.com>.
On 10/12/10 23:14, Benson Margulies wrote:
> I want to make an InfModel that puts an inference engine on top of a
> TDB dataset so that inference happens over the set. If this isn't a
> nutty idea altogether,
Not nutty, but performance may not be great since the inference engine 
makes many queries into the model, and going to disk is slow ...

> is there any way to do this without using the
> assembler?
Yes.

Model baseModel = ... yourTDBModel ...;
OntModel infModel = ModelFactory.createOntologyModel(
	OntModelSpec.OWL_MEM_MICRO_RULE_INF, 	// deductions in memory
	baseModel 				// axioms in TDB
);


Ian

-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
               Portishead, Bristol BS20 6PT, UK