You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by tina sani <ti...@gmail.com> on 2016/11/08 16:31:51 UTC

Queries against rules

Hello
I have a text file, having more than twenty Jena rules. Usually we need
SPARQL queries to execute and display the inference results.

For my twenty rules, I need more or less ten queries, so what will be the
sequence and proper way to use SPARQL queries?
I have some inverse property rules, symmetric, transitive and most are Jena
generic rules used in the text file.

Thanks a lot.

Re: Queries against rules

Posted by David Moss <ad...@gmail.com>.
OWL is just one way of specifying relationships. When you build relationships in Protégé you end up with a .owl file that can be imported into Fuseki.
The triple-store will then contain triples describing your objects and their relationships. Some of the relationships stored as triples will be those you set up in Protégé.
Domain and range information for instance. Subclass and superclass. Same-as.Disjoint-with etc. All this is stored in the triple store along with your objects and explicit relationships.

You create an inference model from the data using Jena, then query the inference model.
The reasoner you use on the model will parse the rules and make inferences. 
So if you make cats and dog each a subclass-of mammal and mammal a same-as of animal, a SPARQL query listing all animals will find dog and cat.

Read the link I provided for more.

DM


On 9/11/16, 3:24 am, "tina sani" <ti...@gmail.com> wrote:

    Hello David, I am sorry but I did not understand "use OWL rules in your
    model to create relationships between objects"
    for instance. 
    The Jena rules we use are not OWL specific? You mean rules in the Protege?
    
    On Tue, Nov 8, 2016 at 7:16 PM, David Moss <ad...@gmail.com> wrote:
    
    > It is my understanding that you use OWL rules in your model to create
    > relationships between objects.
    > You can then query the model using SPARQL and a reasoner.
    > The SPARQL will then not only return the triples explicitly matched, but
    > those that can be inferred using the rules too.
    >
    > See https://jena.apache.org/documentation/inference/
    >
    >
    >
    >
    >
    > On 9/11/16, 2:31 am, "tina sani" <ti...@gmail.com> wrote:
    >
    >     Hello
    >     I have a text file, having more than twenty Jena rules. Usually we need
    >     SPARQL queries to execute and display the inference results.
    >
    >     For my twenty rules, I need more or less ten queries, so what will be
    > the
    >     sequence and proper way to use SPARQL queries?
    >     I have some inverse property rules, symmetric, transitive and most are
    > Jena
    >     generic rules used in the text file.
    >
    >     Thanks a lot.
    >
    >
    >
    >
    



Re: Queries against rules

Posted by tina sani <ti...@gmail.com>.
Hello David, I am sorry but I did not understand "use OWL rules in your
model to create relationships between objects"

The Jena rules we use are not OWL specific? You mean rules in the Protege?

On Tue, Nov 8, 2016 at 7:16 PM, David Moss <ad...@gmail.com> wrote:

> It is my understanding that you use OWL rules in your model to create
> relationships between objects.
> You can then query the model using SPARQL and a reasoner.
> The SPARQL will then not only return the triples explicitly matched, but
> those that can be inferred using the rules too.
>
> See https://jena.apache.org/documentation/inference/
>
>
>
>
>
> On 9/11/16, 2:31 am, "tina sani" <ti...@gmail.com> wrote:
>
>     Hello
>     I have a text file, having more than twenty Jena rules. Usually we need
>     SPARQL queries to execute and display the inference results.
>
>     For my twenty rules, I need more or less ten queries, so what will be
> the
>     sequence and proper way to use SPARQL queries?
>     I have some inverse property rules, symmetric, transitive and most are
> Jena
>     generic rules used in the text file.
>
>     Thanks a lot.
>
>
>
>

Re: Queries against rules

Posted by David Moss <ad...@gmail.com>.
It is my understanding that you use OWL rules in your model to create relationships between objects.
You can then query the model using SPARQL and a reasoner.
The SPARQL will then not only return the triples explicitly matched, but those that can be inferred using the rules too.

See https://jena.apache.org/documentation/inference/





On 9/11/16, 2:31 am, "tina sani" <ti...@gmail.com> wrote:

    Hello
    I have a text file, having more than twenty Jena rules. Usually we need
    SPARQL queries to execute and display the inference results.
    
    For my twenty rules, I need more or less ten queries, so what will be the
    sequence and proper way to use SPARQL queries?
    I have some inverse property rules, symmetric, transitive and most are Jena
    generic rules used in the text file.
    
    Thanks a lot.
    



Re: Queries against rules

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.

On 09.11.2016 14:18, tina sani wrote:
> Hello Lorenz, I know rules generate new tripls based on existed data, but I
> have to questions:
>
> (1) We have a model i-e model before Jena rules executes and then after
> inference/rules, our model will be inf, right? If we want to write a model,
> we will use inf.write()?
Yes.
>
> (2) My second query is, after rules, I will have several SPARQL queries run
> against the rules so what will be the order in which we write/run queries.
> It will be like queryString, execute query, then another queryString,
> execute query?
What means "query against rule"? That's totally unclear. You run the
SPARQL query on the inferred model.

And why should the order in which you run the SPARQL queries matter?
What would be the difference if you first run

SELECT * {?s a :cls}

and then

SELECT * {?s ?p ?o}

or vice versa?
>
> Regards
>
> On Wed, Nov 9, 2016 at 10:37 AM, Lorenz B. <
> buehmann@informatik.uni-leipzig.de> wrote:
>
>>> Hello
>>> I have a text file, having more than twenty Jena rules. Usually we need
>>> SPARQL queries to execute and display the inference results.
>>>
>>> For my twenty rules, I need more or less ten queries, so what will be the
>>> sequence and proper way to use SPARQL queries?
>> What means "query for a rule"?
>> Rules are used to infer(generate) additional data based on existing data.
>>
>> 1) Load all rules into a the GenericRuleReasoner and apply it on the
>> original data -> you get a new model
>>
>> Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
>> InfModel inf = ModelFactory.createInfModel(reasoner, rawData);
>>
>>
>> 2) execute the SPARQL query against the new model which contains all the
>> data
>>
>> Lorenz
>>> I have some inverse property rules, symmetric, transitive and most are
>> Jena
>>> generic rules used in the text file.
>>>
>>> Thanks a lot.
>>>
>> --
>> Lorenz B�hmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>


Re: Queries against rules

Posted by tina sani <ti...@gmail.com>.
Hello Lorenz, I know rules generate new tripls based on existed data, but I
have to questions:

(1) We have a model i-e model before Jena rules executes and then after
inference/rules, our model will be inf, right? If we want to write a model,
we will use inf.write()?

(2) My second query is, after rules, I will have several SPARQL queries run
against the rules so what will be the order in which we write/run queries.
It will be like queryString, execute query, then another queryString,
execute query?

Regards

On Wed, Nov 9, 2016 at 10:37 AM, Lorenz B. <
buehmann@informatik.uni-leipzig.de> wrote:

>
> > Hello
> > I have a text file, having more than twenty Jena rules. Usually we need
> > SPARQL queries to execute and display the inference results.
> >
> > For my twenty rules, I need more or less ten queries, so what will be the
> > sequence and proper way to use SPARQL queries?
> What means "query for a rule"?
> Rules are used to infer(generate) additional data based on existing data.
>
> 1) Load all rules into a the GenericRuleReasoner and apply it on the
> original data -> you get a new model
>
> Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
> InfModel inf = ModelFactory.createInfModel(reasoner, rawData);
>
>
> 2) execute the SPARQL query against the new model which contains all the
> data
>
> Lorenz
> > I have some inverse property rules, symmetric, transitive and most are
> Jena
> > generic rules used in the text file.
> >
> > Thanks a lot.
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>

Re: Queries against rules

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
> Hello
> I have a text file, having more than twenty Jena rules. Usually we need
> SPARQL queries to execute and display the inference results.
>
> For my twenty rules, I need more or less ten queries, so what will be the
> sequence and proper way to use SPARQL queries?
What means "query for a rule"?
Rules are used to infer(generate) additional data based on existing data.

1) Load all rules into a the GenericRuleReasoner and apply it on the
original data -> you get a new model

Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
InfModel inf = ModelFactory.createInfModel(reasoner, rawData);


2) execute the SPARQL query against the new model which contains all the
data

Lorenz
> I have some inverse property rules, symmetric, transitive and most are Jena
> generic rules used in the text file.
>
> Thanks a lot.
>
-- 
Lorenz B�hmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center