You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Miguel Bento Alves <mb...@gmail.com> on 2014/05/25 15:51:51 UTC
JENA-650 - Define SPARQL commands in Jena rules
Dear All,
I'm working on JENA-650 - Define SPARQL commands in Jena rules under GSoC
project. I'm starting to study and analyse the relevant libraries and the
coding relevants to my work.
Can anyone locate for me the libraries/classes where:
a) a rule is parsed;
b) a rule is executed;
c) a SPARQL command is parsed;
Thanks, Miguel
Re: JENA-650 - Define SPARQL commands in Jena rules
Posted by Dave Reynolds <da...@gmail.com>.
On 25/05/14 14:51, Miguel Bento Alves wrote:
> Dear All,
>
> I'm working on JENA-650 - Define SPARQL commands in Jena rules under GSoC
> project. I'm starting to study and analyse the relevant libraries and the
> coding relevants to my work.
>
> Can anyone locate for me the libraries/classes where:
> a) a rule is parsed;
com.hp.hpl.jena.reasoner.rulesys.Rule.Parser
As Joshua says, this is something you could find out using an IDE.
> b) a rule is executed;
There is no one place. Ignoring the legacy brute force forward engine
[1] then there are two rule engines - the RETE-ish forward engine and
the SLG-ish backward engine. Both are in
com.hp.hpl.jena.reasoner.rulesys.impl, look for RETE* and LP* respectively.
As I said when this was first suggested it is not easy to see how to
hook SPARQL in to either of them, though the backward engine is probably
the better suited.
Dave
[1] com.hp.hpl.jena.reasoner.rulesys.impl.FRuleEngine
Re: JENA-650 - Define SPARQL commands in Jena rules
Posted by Andy Seaborne <an...@apache.org>.
Hi Miguel,
The SPARQL parser can be invoked via:
QueryFactory.create
It calls
SPARQLParser.create(Syntax)
which checks the registered language to find a factory for the right
language. The factory creates a parser instance.
QueryFactory calls the parser with a Query object to be filled in. The
parser is a one-use object.
Normally there are three languages registered: SPARQL 1.0, SPARQL 1.1
amd ARQ (extended superset of SPARQL 1.1). The default is SPARQL 1.1.
(except Fuseki, which uses Syntax.ARQ -- there isn't a lot of difference
between SPARQL 1.1 and ARQ these days).
The result object "Query" is built in the parsing process. That gets
passed to the QueryExecFactory to look for the right engine to execute
that query/data source combination. The general purpose QueryEngineMain
can execute any query so there is always a way to execute a query.
Query object can be used for executions multiple times. Once built,
they are (should be) immutable.
Andy
On 26/05/14 02:54, Joshua TAYLOR wrote:
> I'm not near a Jena source archive at the moment, but there's code in
> the tutorials, e.g., the inference support document [1] that includes
> code sames that use this functionality, e.g.,
>
> String rules = "[rule1: (?a eg:p ?b) (?b eg:p ?c) -> (?a eg:p ?c)]";
> Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
> reasoner.setDerivationLogging(true);
> InfModel inf = ModelFactory.createInfModel(reasoner, rawData);
>
> A Java IDE (e.g., Eclipse) should give you a "find source"
> functionality so that you can select Rule.parseRules and "goto
> source". In some aspects, things get a little more complicated with
> Interface and InterfaceImpl hierarchies, but generally this will get
> you started…
>
>
> [1] http://jena.apache.org/documentation/inference/
>
> On Sun, May 25, 2014 at 9:51 AM, Miguel Bento Alves
> <mb...@gmail.com> wrote:
>> Dear All,
>>
>> I'm working on JENA-650 - Define SPARQL commands in Jena rules under GSoC
>> project. I'm starting to study and analyse the relevant libraries and the
>> coding relevants to my work.
>>
>> Can anyone locate for me the libraries/classes where:
>> a) a rule is parsed;
>> b) a rule is executed;
>> c) a SPARQL command is parsed;
>>
>> Thanks, Miguel
>>
>>
>
>
>
Re: JENA-650 - Define SPARQL commands in Jena rules
Posted by Joshua TAYLOR <jo...@gmail.com>.
I'm not near a Jena source archive at the moment, but there's code in
the tutorials, e.g., the inference support document [1] that includes
code sames that use this functionality, e.g.,
String rules = "[rule1: (?a eg:p ?b) (?b eg:p ?c) -> (?a eg:p ?c)]";
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
reasoner.setDerivationLogging(true);
InfModel inf = ModelFactory.createInfModel(reasoner, rawData);
A Java IDE (e.g., Eclipse) should give you a "find source"
functionality so that you can select Rule.parseRules and "goto
source". In some aspects, things get a little more complicated with
Interface and InterfaceImpl hierarchies, but generally this will get
you started…
[1] http://jena.apache.org/documentation/inference/
On Sun, May 25, 2014 at 9:51 AM, Miguel Bento Alves
<mb...@gmail.com> wrote:
> Dear All,
>
> I'm working on JENA-650 - Define SPARQL commands in Jena rules under GSoC
> project. I'm starting to study and analyse the relevant libraries and the
> coding relevants to my work.
>
> Can anyone locate for me the libraries/classes where:
> a) a rule is parsed;
> b) a rule is executed;
> c) a SPARQL command is parsed;
>
> Thanks, Miguel
>
>
--
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/