Re: CONSTRUCT query with rsparql

2023-06-14 Thread Martynas Jusevičius
Sorry, I meant this:



CONSTRUCT
  {
?s ?p ?o .
  }
WHERE
  { ?s  ?p?o ;
  "the message"
  }

On Wed, Jun 14, 2023 at 12:23 PM Martynas Jusevičius
 wrote:
>
> No syntax issue, but with ?o being not bound the ?s ?p ?o triple will
> not be constructed.
>
> This might or might not be what you are looking for:
>
> CONSTRUCT
>   {
> ?s ?p ?o .
>   }
> WHERE
>   { ?s    ?o ;
>   "the message"
>   }
>
> On Wed, Jun 14, 2023 at 12:13 PM Hashim Khan  
> wrote:
> >
> > Thanks for the quick response. I would ask if you write the exact query
> > please. By, ?o not bound, you mean that we can not execute such a
> > construct query? Or is there a syntax issue?
> >
> > On Wed, Jun 14, 2023 at 12:04 PM Martynas Jusevičius 
> > 
> > wrote:
> >
> > > ?o is not bound in your WHERE pattern.
> > >
> > > On Wed, Jun 14, 2023 at 11:50 AM Hashim Khan 
> > > wrote:
> > > >
> > > > Hi,
> > > >
> > > > ./rsparql --service http://localhost:8890/sparql --query query.sparql
> > > > --results=ntriples I want to save the triples in NT format as returned 
> > > > by
> > > > the construct query given here.
> > > > CONSTRUCT {?s ?p ?o} WHERE {
> > > >?s  'the message' .
> > > > }
> > > >
> > > > I have run this query with SELECT and it has many triples, but when I
> > > want
> > > > to construct them, then I can not see the effect. It takes about two
> > > > seconds but neither output.nt file generates, nor I see any triples. If
> > > > anyone please tell me the exact query to accomplish this job.
> > > >
> > > > best regards
> > > > --
> > > > *Hashim Khan*
> > >
> >
> >
> > --
> > *Hashim Khan*


Re: CONSTRUCT query with rsparql

2023-06-14 Thread Martynas Jusevičius
No syntax issue, but with ?o being not bound the ?s ?p ?o triple will
not be constructed.

This might or might not be what you are looking for:

CONSTRUCT
  {
?s ?p ?o .
  }
WHERE
  { ?s    ?o ;
  "the message"
  }

On Wed, Jun 14, 2023 at 12:13 PM Hashim Khan  wrote:
>
> Thanks for the quick response. I would ask if you write the exact query
> please. By, ?o not bound, you mean that we can not execute such a
> construct query? Or is there a syntax issue?
>
> On Wed, Jun 14, 2023 at 12:04 PM Martynas Jusevičius 
> wrote:
>
> > ?o is not bound in your WHERE pattern.
> >
> > On Wed, Jun 14, 2023 at 11:50 AM Hashim Khan 
> > wrote:
> > >
> > > Hi,
> > >
> > > ./rsparql --service http://localhost:8890/sparql --query query.sparql
> > > --results=ntriples I want to save the triples in NT format as returned by
> > > the construct query given here.
> > > CONSTRUCT {?s ?p ?o} WHERE {
> > >?s  'the message' .
> > > }
> > >
> > > I have run this query with SELECT and it has many triples, but when I
> > want
> > > to construct them, then I can not see the effect. It takes about two
> > > seconds but neither output.nt file generates, nor I see any triples. If
> > > anyone please tell me the exact query to accomplish this job.
> > >
> > > best regards
> > > --
> > > *Hashim Khan*
> >
>
>
> --
> *Hashim Khan*


Re: CONSTRUCT query with rsparql

2023-06-14 Thread Hashim Khan
Thanks for the quick response. I would ask if you write the exact query
please. By, ?o not bound, you mean that we can not execute such a
construct query? Or is there a syntax issue?

On Wed, Jun 14, 2023 at 12:04 PM Martynas Jusevičius 
wrote:

> ?o is not bound in your WHERE pattern.
>
> On Wed, Jun 14, 2023 at 11:50 AM Hashim Khan 
> wrote:
> >
> > Hi,
> >
> > ./rsparql --service http://localhost:8890/sparql --query query.sparql
> > --results=ntriples I want to save the triples in NT format as returned by
> > the construct query given here.
> > CONSTRUCT {?s ?p ?o} WHERE {
> >?s  'the message' .
> > }
> >
> > I have run this query with SELECT and it has many triples, but when I
> want
> > to construct them, then I can not see the effect. It takes about two
> > seconds but neither output.nt file generates, nor I see any triples. If
> > anyone please tell me the exact query to accomplish this job.
> >
> > best regards
> > --
> > *Hashim Khan*
>


-- 
*Hashim Khan*


Re: CONSTRUCT query with rsparql

2023-06-14 Thread Martynas Jusevičius
?o is not bound in your WHERE pattern.

On Wed, Jun 14, 2023 at 11:50 AM Hashim Khan  wrote:
>
> Hi,
>
> ./rsparql --service http://localhost:8890/sparql --query query.sparql
> --results=ntriples I want to save the triples in NT format as returned by
> the construct query given here.
> CONSTRUCT {?s ?p ?o} WHERE {
>?s  'the message' .
> }
>
> I have run this query with SELECT and it has many triples, but when I want
> to construct them, then I can not see the effect. It takes about two
> seconds but neither output.nt file generates, nor I see any triples. If
> anyone please tell me the exact query to accomplish this job.
>
> best regards
> --
> *Hashim Khan*


Re: Construct query for Rules

2017-09-14 Thread javed khan
Thank you Lorenz for your help.



On Thu, Sep 14, 2017 at 8:30 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> On 14.09.2017 15:15, javed khan wrote:
> > Hello Lorenz, I have class Student which have sub classes "Researcher (if
> > publication>10), Assistant (if publications >7) and Junior Student. The
> > instances of these classes are assigned using Construct query as shown in
> > my previous email.
> >
> > I want to store it also in file as other data of students name,
> department
> > etc are already in the file. Earlier I used Jena rules and it was stored
> in
> > the file.
> >
> > **If you want to have the additional triples in the same file, you
> > have to add the triples to the original model and write this model back
> > to file.
> >
> > It means Lorenz, I have to add the "results" model Of Construct query to
> > the other model which have all other data and then store/write it to the
> > file?
> >
> > model.add(results)
> Yes, this should be quite obvious: you have a model A which is basically
> a set of triples and based on this model you compute a new model B
> containing another, possibly new set of triples. Indeed, you want to
> have the union of both, thus, add B to A.
> An alternative would be directly modify model A by means of a SPARQL
> update query, but it wouldn't change the overall result.
> >
> > On Thu, Sep 14, 2017 at 3:07 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >>
> >> On 12.09.2017 22:01, javed khan wrote:
> >>> Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and
> it
> >>> works.
> >>>
> >>> But to write it to the file, we have the OntModel (model1) as:
> >>>
> >>> try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
> >>>   model1.write(writer, "RDF/XML");
> >>>
> >>> But after we run the Construct query, we will have another model like:
> >>>
> >>> Model results= qexec.execConstruct() ;
> >>> results.write(System.out, "TURTLE");
> >> That model contains only the new triples, not the old ones.
> >>> So we should write it separate to the file? I tried this but it did not
> >>> work. In fact, it over-write the already data in the file.
> >> I don't get it as I don't understand what you want to achieve in the
> >> end. If you want to have the additional triples in the same file, you
> >> have to add the triples to the original model and write this model back
> >> to file.
> >>
> >>> //The query work fine if we write to console.
> >>>
> >>> On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> > "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
>  That has nothing to do with Jena - It's SPARQL syntax and as Dave
>  already pointed out,
>  '10' is a string literal - either use "10"^^xsd:integer or the
> shortcut
>  10 . See the Turtle syntax for RDF and look into the SPARQL specs.
> > On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Show code + data, otherwise nobody can help you ...
> >>
> >> That's the simplest way, a SPARQL query for each rule - don't make
> it
> >> more complicated as necessary.
> >>
> >> Don't forget (Dave and me already told you that): if you have
> multiple
> >> rules that depend on each other, you have to perform the SPARQL
> >> queries
> >> as long as no new data has been generated ("fix-point iteration") -
> >> with
> >> rules you get this for free by the rule engine.
> >>
> >>
> >> On 11.09.2017 13:09, javed khan wrote:
> >>> Hello Lorenz yes it did not work for me. İ have about sixteen
> similar
> >> types
> >>> of rules and not sure if İ need a separate SPARQL Construct query
> for
> >> each
> >>> rule.
> >>> For example another such type of rule is if a person experience is
> >> more
> >>> than some value, then person is Experience employee and other rules
>  like
> >>> that.
> >>>
> >>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
>  I thought Dave explained this already. Of course you can use a
> >> SPARQL
>  CONSTRUCT query to get the same result as a single Jena rule.
> 
>  The answer is, yes. Your query should do the same as your rule.
> 
>  And I'm wondering why you can't try it out on your data? Does
>  something
>  not work as expected?
> 
> 
>  On 10.09.2017 22:15, javed khan wrote:
> > I am wondering if the following Construct query could lead to the
>  alternate
> > result of the Jena rule (given below)?
> >
> > Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> >> +greaterThan
> > (?No, 10)-> (?x rdf:type :Researcher)
> >
> > Construct Query:
> >
> > Cons

Re: Construct query for Rules

2017-09-14 Thread Lorenz Buehmann


On 14.09.2017 15:15, javed khan wrote:
> Hello Lorenz, I have class Student which have sub classes "Researcher (if
> publication>10), Assistant (if publications >7) and Junior Student. The
> instances of these classes are assigned using Construct query as shown in
> my previous email.
>
> I want to store it also in file as other data of students name, department
> etc are already in the file. Earlier I used Jena rules and it was stored in
> the file.
>
> **If you want to have the additional triples in the same file, you
> have to add the triples to the original model and write this model back
> to file.
>
> It means Lorenz, I have to add the "results" model Of Construct query to
> the other model which have all other data and then store/write it to the
> file?
>
> model.add(results)
Yes, this should be quite obvious: you have a model A which is basically
a set of triples and based on this model you compute a new model B
containing another, possibly new set of triples. Indeed, you want to
have the union of both, thus, add B to A.
An alternative would be directly modify model A by means of a SPARQL
update query, but it wouldn't change the overall result.
>
> On Thu, Sep 14, 2017 at 3:07 PM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>>
>> On 12.09.2017 22:01, javed khan wrote:
>>> Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and it
>>> works.
>>>
>>> But to write it to the file, we have the OntModel (model1) as:
>>>
>>> try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
>>>   model1.write(writer, "RDF/XML");
>>>
>>> But after we run the Construct query, we will have another model like:
>>>
>>> Model results= qexec.execConstruct() ;
>>> results.write(System.out, "TURTLE");
>> That model contains only the new triples, not the old ones.
>>> So we should write it separate to the file? I tried this but it did not
>>> work. In fact, it over-write the already data in the file.
>> I don't get it as I don't understand what you want to achieve in the
>> end. If you want to have the additional triples in the same file, you
>> have to add the triples to the original model and write this model back
>> to file.
>>
>>> //The query work fine if we write to console.
>>>
>>> On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
 That has nothing to do with Jena - It's SPARQL syntax and as Dave
 already pointed out,
 '10' is a string literal - either use "10"^^xsd:integer or the shortcut
 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> Show code + data, otherwise nobody can help you ...
>>
>> That's the simplest way, a SPARQL query for each rule - don't make it
>> more complicated as necessary.
>>
>> Don't forget (Dave and me already told you that): if you have multiple
>> rules that depend on each other, you have to perform the SPARQL
>> queries
>> as long as no new data has been generated ("fix-point iteration") -
>> with
>> rules you get this for free by the rule engine.
>>
>>
>> On 11.09.2017 13:09, javed khan wrote:
>>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
>> types
>>> of rules and not sure if İ need a separate SPARQL Construct query for
>> each
>>> rule.
>>> For example another such type of rule is if a person experience is
>> more
>>> than some value, then person is Experience employee and other rules
 like
>>> that.
>>>
>>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
 I thought Dave explained this already. Of course you can use a
>> SPARQL
 CONSTRUCT query to get the same result as a single Jena rule.

 The answer is, yes. Your query should do the same as your rule.

 And I'm wondering why you can't try it out on your data? Does
 something
 not work as expected?


 On 10.09.2017 22:15, javed khan wrote:
> I am wondering if the following Construct query could lead to the
 alternate
> result of the Jena rule (given below)?
>
> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
>> +greaterThan
> (?No, 10)-> (?x rdf:type :Researcher)
>
> Construct Query:
>
> Construct {?x rdf:type :Researcher}
>
> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> (?No>10) }
>
>>



Re: Construct query for Rules

2017-09-14 Thread javed khan
Hello Lorenz, I have class Student which have sub classes "Researcher (if
publication>10), Assistant (if publications >7) and Junior Student. The
instances of these classes are assigned using Construct query as shown in
my previous email.

I want to store it also in file as other data of students name, department
etc are already in the file. Earlier I used Jena rules and it was stored in
the file.

**If you want to have the additional triples in the same file, you
have to add the triples to the original model and write this model back
to file.

It means Lorenz, I have to add the "results" model Of Construct query to
the other model which have all other data and then store/write it to the
file?

model.add(results)

On Thu, Sep 14, 2017 at 3:07 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> On 12.09.2017 22:01, javed khan wrote:
> > Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and it
> > works.
> >
> > But to write it to the file, we have the OntModel (model1) as:
> >
> > try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
> >   model1.write(writer, "RDF/XML");
> >
> > But after we run the Construct query, we will have another model like:
> >
> > Model results= qexec.execConstruct() ;
> > results.write(System.out, "TURTLE");
> That model contains only the new triples, not the old ones.
> >
> > So we should write it separate to the file? I tried this but it did not
> > work. In fact, it over-write the already data in the file.
> I don't get it as I don't understand what you want to achieve in the
> end. If you want to have the additional triples in the same file, you
> have to add the triples to the original model and write this model back
> to file.
>
> >
> > //The query work fine if we write to console.
> >
> > On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >>> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
> >> That has nothing to do with Jena - It's SPARQL syntax and as Dave
> >> already pointed out,
> >> '10' is a string literal - either use "10"^^xsd:integer or the shortcut
> >> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
> >>> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
>  Show code + data, otherwise nobody can help you ...
> 
>  That's the simplest way, a SPARQL query for each rule - don't make it
>  more complicated as necessary.
> 
>  Don't forget (Dave and me already told you that): if you have multiple
>  rules that depend on each other, you have to perform the SPARQL
> queries
>  as long as no new data has been generated ("fix-point iteration") -
> with
>  rules you get this for free by the rule engine.
> 
> 
>  On 11.09.2017 13:09, javed khan wrote:
> > Hello Lorenz yes it did not work for me. İ have about sixteen similar
>  types
> > of rules and not sure if İ need a separate SPARQL Construct query for
>  each
> > rule.
> > For example another such type of rule is if a person experience is
> more
> > than some value, then person is Experience employee and other rules
> >> like
> > that.
> >
> > On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> I thought Dave explained this already. Of course you can use a
> SPARQL
> >> CONSTRUCT query to get the same result as a single Jena rule.
> >>
> >> The answer is, yes. Your query should do the same as your rule.
> >>
> >> And I'm wondering why you can't try it out on your data? Does
> >> something
> >> not work as expected?
> >>
> >>
> >> On 10.09.2017 22:15, javed khan wrote:
> >>> I am wondering if the following Construct query could lead to the
> >> alternate
> >>> result of the Jena rule (given below)?
> >>>
> >>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
>  +greaterThan
> >>> (?No, 10)-> (?x rdf:type :Researcher)
> >>>
> >>> Construct Query:
> >>>
> >>> Construct {?x rdf:type :Researcher}
> >>>
> >>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> >>> (?No>10) }
> >>>
> >>
>
>


Re: Construct query for Rules

2017-09-14 Thread Lorenz Buehmann


On 12.09.2017 22:01, javed khan wrote:
> Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and it
> works.
>
> But to write it to the file, we have the OntModel (model1) as:
>
> try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
>   model1.write(writer, "RDF/XML");
>
> But after we run the Construct query, we will have another model like:
>
> Model results= qexec.execConstruct() ;
> results.write(System.out, "TURTLE");
That model contains only the new triples, not the old ones.
>
> So we should write it separate to the file? I tried this but it did not
> work. In fact, it over-write the already data in the file.
I don't get it as I don't understand what you want to achieve in the
end. If you want to have the additional triples in the same file, you
have to add the triples to the original model and write this model back
to file.

>
> //The query work fine if we write to console.
>
> On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>>> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
>> That has nothing to do with Jena - It's SPARQL syntax and as Dave
>> already pointed out,
>> '10' is a string literal - either use "10"^^xsd:integer or the shortcut
>> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
>>> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
 Show code + data, otherwise nobody can help you ...

 That's the simplest way, a SPARQL query for each rule - don't make it
 more complicated as necessary.

 Don't forget (Dave and me already told you that): if you have multiple
 rules that depend on each other, you have to perform the SPARQL queries
 as long as no new data has been generated ("fix-point iteration") - with
 rules you get this for free by the rule engine.


 On 11.09.2017 13:09, javed khan wrote:
> Hello Lorenz yes it did not work for me. İ have about sixteen similar
 types
> of rules and not sure if İ need a separate SPARQL Construct query for
 each
> rule.
> For example another such type of rule is if a person experience is more
> than some value, then person is Experience employee and other rules
>> like
> that.
>
> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> I thought Dave explained this already. Of course you can use a SPARQL
>> CONSTRUCT query to get the same result as a single Jena rule.
>>
>> The answer is, yes. Your query should do the same as your rule.
>>
>> And I'm wondering why you can't try it out on your data? Does
>> something
>> not work as expected?
>>
>>
>> On 10.09.2017 22:15, javed khan wrote:
>>> I am wondering if the following Construct query could lead to the
>> alternate
>>> result of the Jena rule (given below)?
>>>
>>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
 +greaterThan
>>> (?No, 10)-> (?x rdf:type :Researcher)
>>>
>>> Construct Query:
>>>
>>> Construct {?x rdf:type :Researcher}
>>>
>>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
>>> (?No>10) }
>>>
>>



Re: Construct query for Rules

2017-09-12 Thread javed khan
Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and it
works.

But to write it to the file, we have the OntModel (model1) as:

try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
  model1.write(writer, "RDF/XML");

But after we run the Construct query, we will have another model like:

Model results= qexec.execConstruct() ;
results.write(System.out, "TURTLE");

So we should write it separate to the file? I tried this but it did not
work. In fact, it over-write the already data in the file.

//The query work fine if we write to console.

On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
> > "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
> That has nothing to do with Jena - It's SPARQL syntax and as Dave
> already pointed out,
> '10' is a string literal - either use "10"^^xsd:integer or the shortcut
> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
> >
> > On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Show code + data, otherwise nobody can help you ...
> >>
> >> That's the simplest way, a SPARQL query for each rule - don't make it
> >> more complicated as necessary.
> >>
> >> Don't forget (Dave and me already told you that): if you have multiple
> >> rules that depend on each other, you have to perform the SPARQL queries
> >> as long as no new data has been generated ("fix-point iteration") - with
> >> rules you get this for free by the rule engine.
> >>
> >>
> >> On 11.09.2017 13:09, javed khan wrote:
> >>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
> >> types
> >>> of rules and not sure if İ need a separate SPARQL Construct query for
> >> each
> >>> rule.
> >>> For example another such type of rule is if a person experience is more
> >>> than some value, then person is Experience employee and other rules
> like
> >>> that.
> >>>
> >>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
>  I thought Dave explained this already. Of course you can use a SPARQL
>  CONSTRUCT query to get the same result as a single Jena rule.
> 
>  The answer is, yes. Your query should do the same as your rule.
> 
>  And I'm wondering why you can't try it out on your data? Does
> something
>  not work as expected?
> 
> 
>  On 10.09.2017 22:15, javed khan wrote:
> > I am wondering if the following Construct query could lead to the
>  alternate
> > result of the Jena rule (given below)?
> >
> > Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> >> +greaterThan
> > (?No, 10)-> (?x rdf:type :Researcher)
> >
> > Construct Query:
> >
> > Construct {?x rdf:type :Researcher}
> >
> > Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> > (?No>10) }
> >
> >>
>
>


Re: Construct query for Rules

2017-09-12 Thread Lorenz Buehmann

> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
That has nothing to do with Jena - It's SPARQL syntax and as Dave
already pointed out,
'10' is a string literal - either use "10"^^xsd:integer or the shortcut
10 . See the Turtle syntax for RDF and look into the SPARQL specs.
>
> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> Show code + data, otherwise nobody can help you ...
>>
>> That's the simplest way, a SPARQL query for each rule - don't make it
>> more complicated as necessary.
>>
>> Don't forget (Dave and me already told you that): if you have multiple
>> rules that depend on each other, you have to perform the SPARQL queries
>> as long as no new data has been generated ("fix-point iteration") - with
>> rules you get this for free by the rule engine.
>>
>>
>> On 11.09.2017 13:09, javed khan wrote:
>>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
>> types
>>> of rules and not sure if İ need a separate SPARQL Construct query for
>> each
>>> rule.
>>> For example another such type of rule is if a person experience is more
>>> than some value, then person is Experience employee and other rules like
>>> that.
>>>
>>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
 I thought Dave explained this already. Of course you can use a SPARQL
 CONSTRUCT query to get the same result as a single Jena rule.

 The answer is, yes. Your query should do the same as your rule.

 And I'm wondering why you can't try it out on your data? Does something
 not work as expected?


 On 10.09.2017 22:15, javed khan wrote:
> I am wondering if the following Construct query could lead to the
 alternate
> result of the Jena rule (given below)?
>
> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
>> +greaterThan
> (?No, 10)-> (?x rdf:type :Researcher)
>
> Construct Query:
>
> Construct {?x rdf:type :Researcher}
>
> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> (?No>10) }
>
>>



Re: Construct query for Rules

2017-09-12 Thread Dave Reynolds

On 12/09/17 00:12, javed khan wrote:

Hello Martynas and Lorenz thank you

I have issue about it.  When I use the filter keyword, the query does not
show the result. When I remove the filter, it writes in console that x is
type of researcher (regardless of any number of publications as there is no
filter) So the problem is in Filter syntax in Jena code. I use Filter as

"FILTER ( ?score > '10' ). "   // is this right syntax in Jena?


Assuming score is a integer then no. That's the SPARQL syntax (this is 
not specific to Jena) for a string. You presumably want:


FILTER ( ?score > 10 ).

Dave





On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:


Show code + data, otherwise nobody can help you ...

That's the simplest way, a SPARQL query for each rule - don't make it
more complicated as necessary.

Don't forget (Dave and me already told you that): if you have multiple
rules that depend on each other, you have to perform the SPARQL queries
as long as no new data has been generated ("fix-point iteration") - with
rules you get this for free by the rule engine.


On 11.09.2017 13:09, javed khan wrote:

Hello Lorenz yes it did not work for me. İ have about sixteen similar

types

of rules and not sure if İ need a separate SPARQL Construct query for

each

rule.
For example another such type of rule is if a person experience is more
than some value, then person is Experience employee and other rules like
that.

On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:


I thought Dave explained this already. Of course you can use a SPARQL
CONSTRUCT query to get the same result as a single Jena rule.

The answer is, yes. Your query should do the same as your rule.

And I'm wondering why you can't try it out on your data? Does something
not work as expected?


On 10.09.2017 22:15, javed khan wrote:

I am wondering if the following Construct query could lead to the

alternate

result of the Jena rule (given below)?

Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)

+greaterThan

(?No, 10)-> (?x rdf:type :Researcher)

Construct Query:

Construct {?x rdf:type :Researcher}

Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
(?No>10) }










Re: Construct query for Rules

2017-09-11 Thread javed khan
Hello Martynas and Lorenz thank you

I have issue about it.  When I use the filter keyword, the query does not
show the result. When I remove the filter, it writes in console that x is
type of researcher (regardless of any number of publications as there is no
filter) So the problem is in Filter syntax in Jena code. I use Filter as

"FILTER ( ?score > '10' ). "   // is this right syntax in Jena?



On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Show code + data, otherwise nobody can help you ...
>
> That's the simplest way, a SPARQL query for each rule - don't make it
> more complicated as necessary.
>
> Don't forget (Dave and me already told you that): if you have multiple
> rules that depend on each other, you have to perform the SPARQL queries
> as long as no new data has been generated ("fix-point iteration") - with
> rules you get this for free by the rule engine.
>
>
> On 11.09.2017 13:09, javed khan wrote:
> > Hello Lorenz yes it did not work for me. İ have about sixteen similar
> types
> > of rules and not sure if İ need a separate SPARQL Construct query for
> each
> > rule.
> > For example another such type of rule is if a person experience is more
> > than some value, then person is Experience employee and other rules like
> > that.
> >
> > On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> I thought Dave explained this already. Of course you can use a SPARQL
> >> CONSTRUCT query to get the same result as a single Jena rule.
> >>
> >> The answer is, yes. Your query should do the same as your rule.
> >>
> >> And I'm wondering why you can't try it out on your data? Does something
> >> not work as expected?
> >>
> >>
> >> On 10.09.2017 22:15, javed khan wrote:
> >>> I am wondering if the following Construct query could lead to the
> >> alternate
> >>> result of the Jena rule (given below)?
> >>>
> >>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> +greaterThan
> >>> (?No, 10)-> (?x rdf:type :Researcher)
> >>>
> >>> Construct Query:
> >>>
> >>> Construct {?x rdf:type :Researcher}
> >>>
> >>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> >>> (?No>10) }
> >>>
> >>
>
>


Re: Construct query for Rules

2017-09-11 Thread Lorenz Buehmann
Show code + data, otherwise nobody can help you ...

That's the simplest way, a SPARQL query for each rule - don't make it
more complicated as necessary.

Don't forget (Dave and me already told you that): if you have multiple
rules that depend on each other, you have to perform the SPARQL queries
as long as no new data has been generated ("fix-point iteration") - with
rules you get this for free by the rule engine.


On 11.09.2017 13:09, javed khan wrote:
> Hello Lorenz yes it did not work for me. İ have about sixteen similar types
> of rules and not sure if İ need a separate SPARQL Construct query for each
> rule.
> For example another such type of rule is if a person experience is more
> than some value, then person is Experience employee and other rules like
> that.
>
> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> I thought Dave explained this already. Of course you can use a SPARQL
>> CONSTRUCT query to get the same result as a single Jena rule.
>>
>> The answer is, yes. Your query should do the same as your rule.
>>
>> And I'm wondering why you can't try it out on your data? Does something
>> not work as expected?
>>
>>
>> On 10.09.2017 22:15, javed khan wrote:
>>> I am wondering if the following Construct query could lead to the
>> alternate
>>> result of the Jena rule (given below)?
>>>
>>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No) +greaterThan
>>> (?No, 10)-> (?x rdf:type :Researcher)
>>>
>>> Construct Query:
>>>
>>> Construct {?x rdf:type :Researcher}
>>>
>>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
>>> (?No>10) }
>>>
>>



Re: Construct query for Rules

2017-09-11 Thread Martynas Jusevičius
* not a valid property

On Mon, Sep 11, 2017 at 1:19 PM, Martynas Jusevičius  wrote:

> Javed,
>
> show the data and the errors.
>
> exp: NoOfPublications is property (with space in the middle).
>
> On Mon, Sep 11, 2017 at 1:09 PM, javed khan  wrote:
>
>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
>> types
>> of rules and not sure if İ need a separate SPARQL Construct query for each
>> rule.
>> For example another such type of rule is if a person experience is more
>> than some value, then person is Experience employee and other rules like
>> that.
>>
>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
>> buehm...@informatik.uni-leipzig.de> wrote:
>>
>> > I thought Dave explained this already. Of course you can use a SPARQL
>> > CONSTRUCT query to get the same result as a single Jena rule.
>> >
>> > The answer is, yes. Your query should do the same as your rule.
>> >
>> > And I'm wondering why you can't try it out on your data? Does something
>> > not work as expected?
>> >
>> >
>> > On 10.09.2017 22:15, javed khan wrote:
>> > > I am wondering if the following Construct query could lead to the
>> > alternate
>> > > result of the Jena rule (given below)?
>> > >
>> > > Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
>> +greaterThan
>> > > (?No, 10)-> (?x rdf:type :Researcher)
>> > >
>> > > Construct Query:
>> > >
>> > > Construct {?x rdf:type :Researcher}
>> > >
>> > > Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
>> > > (?No>10) }
>> > >
>> >
>> >
>>
>
>


Re: Construct query for Rules

2017-09-11 Thread Martynas Jusevičius
Javed,

show the data and the errors.

exp: NoOfPublications is property (with space in the middle).

On Mon, Sep 11, 2017 at 1:09 PM, javed khan  wrote:

> Hello Lorenz yes it did not work for me. İ have about sixteen similar types
> of rules and not sure if İ need a separate SPARQL Construct query for each
> rule.
> For example another such type of rule is if a person experience is more
> than some value, then person is Experience employee and other rules like
> that.
>
> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
> > I thought Dave explained this already. Of course you can use a SPARQL
> > CONSTRUCT query to get the same result as a single Jena rule.
> >
> > The answer is, yes. Your query should do the same as your rule.
> >
> > And I'm wondering why you can't try it out on your data? Does something
> > not work as expected?
> >
> >
> > On 10.09.2017 22:15, javed khan wrote:
> > > I am wondering if the following Construct query could lead to the
> > alternate
> > > result of the Jena rule (given below)?
> > >
> > > Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> +greaterThan
> > > (?No, 10)-> (?x rdf:type :Researcher)
> > >
> > > Construct Query:
> > >
> > > Construct {?x rdf:type :Researcher}
> > >
> > > Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> > > (?No>10) }
> > >
> >
> >
>


Re: Construct query for Rules

2017-09-11 Thread javed khan
Hello Lorenz yes it did not work for me. İ have about sixteen similar types
of rules and not sure if İ need a separate SPARQL Construct query for each
rule.
For example another such type of rule is if a person experience is more
than some value, then person is Experience employee and other rules like
that.

On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> I thought Dave explained this already. Of course you can use a SPARQL
> CONSTRUCT query to get the same result as a single Jena rule.
>
> The answer is, yes. Your query should do the same as your rule.
>
> And I'm wondering why you can't try it out on your data? Does something
> not work as expected?
>
>
> On 10.09.2017 22:15, javed khan wrote:
> > I am wondering if the following Construct query could lead to the
> alternate
> > result of the Jena rule (given below)?
> >
> > Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No) +greaterThan
> > (?No, 10)-> (?x rdf:type :Researcher)
> >
> > Construct Query:
> >
> > Construct {?x rdf:type :Researcher}
> >
> > Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> > (?No>10) }
> >
>
>


Re: Construct query for Rules

2017-09-11 Thread Lorenz Buehmann
I thought Dave explained this already. Of course you can use a SPARQL
CONSTRUCT query to get the same result as a single Jena rule.

The answer is, yes. Your query should do the same as your rule.

And I'm wondering why you can't try it out on your data? Does something
not work as expected?


On 10.09.2017 22:15, javed khan wrote:
> I am wondering if the following Construct query could lead to the alternate
> result of the Jena rule (given below)?
>
> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No) +greaterThan
> (?No, 10)-> (?x rdf:type :Researcher)
>
> Construct Query:
>
> Construct {?x rdf:type :Researcher}
>
> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> (?No>10) }
>



Re: Construct query from DBpedia

2017-08-22 Thread Andy Seaborne

Loosely, yes.

A CONSTRUCT query returns a result which is an RDF model.

If that is across then that is work, it is a copy. (well, the 
serialization of results).



Andy

On 22/08/17 16:22, Sidra shah wrote:

Hello Andy, it copies the triples from Dbpedia to the local model?


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Aug 22, 2017 at 5:44 PM, Andy Seaborne  wrote:


It creates a separate model with all the matching triples in it and
nothing else.

It can also be written:

CONSTRUCT WHERE { :France onto:anthem ?x }

 Andy


On 22/08/17 14:04, Sidra shah wrote:


Hello

What is the purpose of this query? The where clause shows the triple
already exist but then why one would need it in Construct?

PREFIX : 
PREFIX onto: 

CONSTRUCT {
  :France onto:anthem ?x
}

WHERE
{
:France onto:anthem ?x .
}







Re: Construct query from DBpedia

2017-08-22 Thread Sidra shah
Hello Andy, it copies the triples from Dbpedia to the local model?


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Aug 22, 2017 at 5:44 PM, Andy Seaborne  wrote:

> It creates a separate model with all the matching triples in it and
> nothing else.
>
> It can also be written:
>
> CONSTRUCT WHERE { :France onto:anthem ?x }
>
> Andy
>
>
> On 22/08/17 14:04, Sidra shah wrote:
>
>> Hello
>>
>> What is the purpose of this query? The where clause shows the triple
>> already exist but then why one would need it in Construct?
>>
>> PREFIX : 
>> PREFIX onto: 
>>
>> CONSTRUCT {
>>  :France onto:anthem ?x
>> }
>>
>> WHERE
>> {
>>:France onto:anthem ?x .
>> }
>>
>


Re: Construct query from DBpedia

2017-08-22 Thread Andy Seaborne
It creates a separate model with all the matching triples in it and 
nothing else.


It can also be written:

CONSTRUCT WHERE { :France onto:anthem ?x }

Andy

On 22/08/17 14:04, Sidra shah wrote:

Hello

What is the purpose of this query? The where clause shows the triple
already exist but then why one would need it in Construct?

PREFIX : 
PREFIX onto: 

CONSTRUCT {
 :France onto:anthem ?x
}

WHERE
{
   :France onto:anthem ?x .
}


Re: Construct query

2017-06-27 Thread Lorenz Buehmann
Then I have to say you did not read it carefully...

CONSTRUCT queries return a set of proper RDF triples, a SELECT query
obviously not since those return an arbitrary resultset.


On 26.06.2017 16:42, tina sani wrote:
> Hello Lorenz, I have read these plus some other too. I read the following
> query but already we have Steve Jobs nationality on DBpedia, why we needed
> Construct query here. We could easily get this data using Select:
> dbr:Steve_Jobs dbp:nationality ?nationality
>
> Why we need Construct query here.
>
> CONSTRUCT {
>  <
> http://dbpedia.org/property/nationality> ?nationality.
> }
> WHERE{
>  <
> http://dbpedia.org/property/nationality> ?nationality.
>
>
>
> On Sun, Jun 25, 2017 at 2:36 PM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> As always, read the SPARQL 1.1 documentation [1]
>>
>> And to answer it, it generates exactly the data that you define in the
>> first part of the CONSTRUCT query such that if there are variables those
>> are bound in the WHERE part.
>>
>> [1] https://www.w3.org/TR/sparql11-query/#construct
>>> Hi
>>>
>>> How a SPARQL construct query works? How it generate data which is not
>>> existed in our ontologies? Is it just create the instances of classes
>> which
>>> does not exist?
>>>
>>> A simple example will be appreciated as I am reading literature about it
>>> from past few days but could not understand how exactly it works.
>>>
>>> Warm regards
>>>
>> --
>> Lorenz Bühmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>



Re: Construct query

2017-06-26 Thread tina sani
Hello Lorenz, I have read these plus some other too. I read the following
query but already we have Steve Jobs nationality on DBpedia, why we needed
Construct query here. We could easily get this data using Select:
dbr:Steve_Jobs dbp:nationality ?nationality

Why we need Construct query here.

CONSTRUCT {
 <
http://dbpedia.org/property/nationality> ?nationality.
}
WHERE{
 <
http://dbpedia.org/property/nationality> ?nationality.



On Sun, Jun 25, 2017 at 2:36 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> As always, read the SPARQL 1.1 documentation [1]
>
> And to answer it, it generates exactly the data that you define in the
> first part of the CONSTRUCT query such that if there are variables those
> are bound in the WHERE part.
>
> [1] https://www.w3.org/TR/sparql11-query/#construct
> > Hi
> >
> > How a SPARQL construct query works? How it generate data which is not
> > existed in our ontologies? Is it just create the instances of classes
> which
> > does not exist?
> >
> > A simple example will be appreciated as I am reading literature about it
> > from past few days but could not understand how exactly it works.
> >
> > Warm regards
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: Construct query

2017-06-25 Thread Lorenz B.
As always, read the SPARQL 1.1 documentation [1]

And to answer it, it generates exactly the data that you define in the
first part of the CONSTRUCT query such that if there are variables those
are bound in the WHERE part.

[1] https://www.w3.org/TR/sparql11-query/#construct
> Hi
>
> How a SPARQL construct query works? How it generate data which is not
> existed in our ontologies? Is it just create the instances of classes which
> does not exist?
>
> A simple example will be appreciated as I am reading literature about it
> from past few days but could not understand how exactly it works.
>
> Warm regards
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: Construct query

2016-10-01 Thread Paul Tyson
On Sat, 2016-10-01 at 03:10 -0700, neha gupta wrote:
> Paul, thank you.
> 
> If I have Student/University ontology and the ontology does not have
> "hasResearch" property can we create like this:
> 
> CONSTRUCT {?s ex:hasResearch ?research}
> WHERE {?s rdf:type ex:Student;ex:hasResearch  "C-SPARQL"}
> 
> to create the property and assign instance to it?

That wouldn't construct any triple because ?research will never be bound
by the WHERE clause. If you ever have a question about what triples will
be constructed, just change the CONSTRUCT {...} to SELECT * and see what
results you get. For every result record, CONSTRUCT will create triples
from the patterns whose variables are bound in the result set.

But now I'm not sure whether you are trying to extend the schema (or
ontology), or just assigning properties to existing subjects.

To add ex:hasResearch into the dataset as an rdf:Property you would just
load some triples like:

ex:hasResearch a rdf:Property;
  rdfs:domain ex:Student;
  rdfs:range [owl:oneOf ("C-SPARQL" "RIF" "SPIN")].

If you want to do any kind of OWL reasoning over your dataset you would
need to add some more statements to associate ex:hasResearch as a data
property of ex:Student.

On the other hand, if you just want to say that all students who are
taking a course called "Intro to SPARQL" will "have
research"="C-SPARQL", that would be like:

CONSTRUCT {?s ex:hasResearch "C-SPARQL"}
WHERE {?s rdf:type ex:Student; ex:hasCourse/rdfs:label "Intro to
SPARQL"}

Regards,
--Paul

> 
> On Fri, Sep 30, 2016 at 8:52 PM, Paul Tyson  wrote:
> 
> > On Thu, 2016-09-29 at 13:44 -0700, tina sani wrote:
> > > I want to know about the Construct query.
> > > How it differs from Select query
> >
> > One way to think about it, if you have any background in relational
> > databases, is that SELECT returns a highly denormalized table (at least,
> > from any non-trivial query). On the other hand, CONSTRUCT will give you
> > an over-normalized set of tables, if you think of each RDF property
> > triple (or quad, if you include graph uri) as an RDBMS table.
> >
> > That is a very abstract view. Syntactically, the results of CONSTRUCT
> > and SELECT are quite different. SELECT must be serialized into something
> > like a table model (csv or the isomorphic xml, json, or text versions).
> > CONSTRUCT results are serialized into some RDF format.
> >
> > > Is it create a new property/class which is not already in the ontology or
> > > it just creates new triples.
> >
> > You can do either (or both). You can use CONSTRUCT to extract a
> > subgraph, or to create new triples based on some rules about the
> > existing data.
> >
> > > I will appreciate if some one come with a simple example. I have searched
> > > web, but could not grasp it.
> >
> > Extract a subgraph. Just get rdf:type and rdfs:label of all subjects.
> > CONSTRUCT {?s rdf:type ?type;rdfs:label ?label}
> > WHERE {?s rdf:type ?type;rdfs:label ?label}
> >
> > Make a new statement based on certain conditions in the dataset.
> > CONSTRUCT {?s :new-property false}
> > WHERE {?s rdf:type ex:TypeA;ex:property1 "A"}
> >
> > Materialize superclass properties:
> > CONSTRUCT {?s rdf:type ?super}
> > WHERE {?s rdf:type ?type;?type rdfs:subClassOf* ?super}
> >
> > As another responder mentioned, CONSTRUCT just returns the triples--it
> > does not modify the dataset. Use a SPARQL update statement
> > (INSERT/WHERE) for that. I've found that with complex or large results
> > it is better in jena to do a CONSTRUCT query and then load the triples
> > into the TDB repository, rather than do an INSERT/WHERE update, which
> > can exhaust resources if the resulting graph is large.
> >
> > Hope this helps.
> >
> > Regards,
> > --Paul
> >
> >




Re: Construct query

2016-10-01 Thread neha gupta
Actually I have the same query like Tina, but can you explain it in term of
a Student ontology because I understand the Student ontology more.

Like Student hasCourse ?course.
Teacher teaches ?course

On Sat, Oct 1, 2016 at 3:10 AM, neha gupta  wrote:

> Paul, thank you.
>
> If I have Student/University ontology and the ontology does not have
> "hasResearch" property can we create like this:
>
> CONSTRUCT {?s ex:hasResearch ?research}
> WHERE {?s rdf:type ex:Student;ex:hasResearch  "C-SPARQL"}
>
> to create the property and assign instance to it?
>
> On Fri, Sep 30, 2016 at 8:52 PM, Paul Tyson  wrote:
>
>> On Thu, 2016-09-29 at 13:44 -0700, tina sani wrote:
>> > I want to know about the Construct query.
>> > How it differs from Select query
>>
>> One way to think about it, if you have any background in relational
>> databases, is that SELECT returns a highly denormalized table (at least,
>> from any non-trivial query). On the other hand, CONSTRUCT will give you
>> an over-normalized set of tables, if you think of each RDF property
>> triple (or quad, if you include graph uri) as an RDBMS table.
>>
>> That is a very abstract view. Syntactically, the results of CONSTRUCT
>> and SELECT are quite different. SELECT must be serialized into something
>> like a table model (csv or the isomorphic xml, json, or text versions).
>> CONSTRUCT results are serialized into some RDF format.
>>
>> > Is it create a new property/class which is not already in the ontology
>> or
>> > it just creates new triples.
>>
>> You can do either (or both). You can use CONSTRUCT to extract a
>> subgraph, or to create new triples based on some rules about the
>> existing data.
>>
>> > I will appreciate if some one come with a simple example. I have
>> searched
>> > web, but could not grasp it.
>>
>> Extract a subgraph. Just get rdf:type and rdfs:label of all subjects.
>> CONSTRUCT {?s rdf:type ?type;rdfs:label ?label}
>> WHERE {?s rdf:type ?type;rdfs:label ?label}
>>
>> Make a new statement based on certain conditions in the dataset.
>> CONSTRUCT {?s :new-property false}
>> WHERE {?s rdf:type ex:TypeA;ex:property1 "A"}
>>
>> Materialize superclass properties:
>> CONSTRUCT {?s rdf:type ?super}
>> WHERE {?s rdf:type ?type;?type rdfs:subClassOf* ?super}
>>
>> As another responder mentioned, CONSTRUCT just returns the triples--it
>> does not modify the dataset. Use a SPARQL update statement
>> (INSERT/WHERE) for that. I've found that with complex or large results
>> it is better in jena to do a CONSTRUCT query and then load the triples
>> into the TDB repository, rather than do an INSERT/WHERE update, which
>> can exhaust resources if the resulting graph is large.
>>
>> Hope this helps.
>>
>> Regards,
>> --Paul
>>
>>
>


Re: Construct query

2016-10-01 Thread neha gupta
Paul, thank you.

If I have Student/University ontology and the ontology does not have
"hasResearch" property can we create like this:

CONSTRUCT {?s ex:hasResearch ?research}
WHERE {?s rdf:type ex:Student;ex:hasResearch  "C-SPARQL"}

to create the property and assign instance to it?

On Fri, Sep 30, 2016 at 8:52 PM, Paul Tyson  wrote:

> On Thu, 2016-09-29 at 13:44 -0700, tina sani wrote:
> > I want to know about the Construct query.
> > How it differs from Select query
>
> One way to think about it, if you have any background in relational
> databases, is that SELECT returns a highly denormalized table (at least,
> from any non-trivial query). On the other hand, CONSTRUCT will give you
> an over-normalized set of tables, if you think of each RDF property
> triple (or quad, if you include graph uri) as an RDBMS table.
>
> That is a very abstract view. Syntactically, the results of CONSTRUCT
> and SELECT are quite different. SELECT must be serialized into something
> like a table model (csv or the isomorphic xml, json, or text versions).
> CONSTRUCT results are serialized into some RDF format.
>
> > Is it create a new property/class which is not already in the ontology or
> > it just creates new triples.
>
> You can do either (or both). You can use CONSTRUCT to extract a
> subgraph, or to create new triples based on some rules about the
> existing data.
>
> > I will appreciate if some one come with a simple example. I have searched
> > web, but could not grasp it.
>
> Extract a subgraph. Just get rdf:type and rdfs:label of all subjects.
> CONSTRUCT {?s rdf:type ?type;rdfs:label ?label}
> WHERE {?s rdf:type ?type;rdfs:label ?label}
>
> Make a new statement based on certain conditions in the dataset.
> CONSTRUCT {?s :new-property false}
> WHERE {?s rdf:type ex:TypeA;ex:property1 "A"}
>
> Materialize superclass properties:
> CONSTRUCT {?s rdf:type ?super}
> WHERE {?s rdf:type ?type;?type rdfs:subClassOf* ?super}
>
> As another responder mentioned, CONSTRUCT just returns the triples--it
> does not modify the dataset. Use a SPARQL update statement
> (INSERT/WHERE) for that. I've found that with complex or large results
> it is better in jena to do a CONSTRUCT query and then load the triples
> into the TDB repository, rather than do an INSERT/WHERE update, which
> can exhaust resources if the resulting graph is large.
>
> Hope this helps.
>
> Regards,
> --Paul
>
>


Re: Construct query

2016-09-30 Thread Paul Tyson
On Thu, 2016-09-29 at 13:44 -0700, tina sani wrote:
> I want to know about the Construct query.
> How it differs from Select query

One way to think about it, if you have any background in relational
databases, is that SELECT returns a highly denormalized table (at least,
from any non-trivial query). On the other hand, CONSTRUCT will give you
an over-normalized set of tables, if you think of each RDF property
triple (or quad, if you include graph uri) as an RDBMS table.

That is a very abstract view. Syntactically, the results of CONSTRUCT
and SELECT are quite different. SELECT must be serialized into something
like a table model (csv or the isomorphic xml, json, or text versions).
CONSTRUCT results are serialized into some RDF format.

> Is it create a new property/class which is not already in the ontology or
> it just creates new triples.

You can do either (or both). You can use CONSTRUCT to extract a
subgraph, or to create new triples based on some rules about the
existing data.

> I will appreciate if some one come with a simple example. I have searched
> web, but could not grasp it.

Extract a subgraph. Just get rdf:type and rdfs:label of all subjects.
CONSTRUCT {?s rdf:type ?type;rdfs:label ?label}
WHERE {?s rdf:type ?type;rdfs:label ?label}

Make a new statement based on certain conditions in the dataset.
CONSTRUCT {?s :new-property false}
WHERE {?s rdf:type ex:TypeA;ex:property1 "A"}

Materialize superclass properties:
CONSTRUCT {?s rdf:type ?super}
WHERE {?s rdf:type ?type;?type rdfs:subClassOf* ?super}

As another responder mentioned, CONSTRUCT just returns the triples--it
does not modify the dataset. Use a SPARQL update statement
(INSERT/WHERE) for that. I've found that with complex or large results
it is better in jena to do a CONSTRUCT query and then load the triples
into the TDB repository, rather than do an INSERT/WHERE update, which
can exhaust resources if the resulting graph is large.

Hope this helps.

Regards,
--Paul



Re: Construct query

2016-09-30 Thread Stian Soiland-Reyes
Important to notice is that the CONSTRUCTed triples are just returned to
the caller, they are not added to the graph. It can be useful to reshape
RDF, e.g. swap properties or simplify relationships.

On 30 Sep 2016 10:32 a.m., "Lorenz B." 
wrote:

> SPARQL CONSTRUCT returns an RDF graph or basically, a set of property
> RDF triples.
>
> > I want to know about the Construct query.
> > How it differs from Select query
> > Is it create a new property/class which is not already in the ontology or
> > it just creates new triples.
> > I will appreciate if some one come with a simple example. I have searched
> > web, but could not grasp it.
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: Construct query

2016-09-30 Thread Lorenz B.
SPARQL CONSTRUCT returns an RDF graph or basically, a set of property
RDF triples.

> I want to know about the Construct query.
> How it differs from Select query
> Is it create a new property/class which is not already in the ontology or
> it just creates new triples.
> I will appreciate if some one come with a simple example. I have searched
> web, but could not grasp it.
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: Construct query

2016-09-29 Thread A. Soroka
Did you read the examples in the spec? They are quite illuminative.

https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#construct

---
A. Soroka
The University of Virginia Library

> On Sep 29, 2016, at 4:44 PM, tina sani  wrote:
> 
> I want to know about the Construct query.
> How it differs from Select query
> Is it create a new property/class which is not already in the ontology or
> it just creates new triples.
> I will appreciate if some one come with a simple example. I have searched
> web, but could not grasp it.