You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by javed khan <ja...@gmail.com> on 2018/05/08 12:24:23 UTC

Repetition of Subject in SPARQL query

Hello

I have a SPARQL query which results a particular study (article) uses
Decision Tree model and NASA, Maxwell, COCOMO datasets.The answer it shows
like for Study 1:

Decision Tree    NASA
Decision Tree    Maxwell
Decision Tree    COCOMO

While I need like this:

Decision Tree  NASA
                        Maxwell
                        COCOMO


The subject should not be repeated,kindly if some one could guide?

Regards

Re: Repetition of Subject in SPARQL query

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
As said before, you can't change the nature of a SPARQL SELECT query -
there are two options:

1) at client side, improve the rendering of the result - it's trivial to
group by the subject ?x

2) which brings us directly to the second option, use GROUP BY on ?x
with GROUP_CONCAT as aggregate function - but, unsurprisingly, due to
the nature of SPARQL, you'll
    get a single row per subject ?x. what does this mean? well, again at
client side you'd have to adapt the rendering of the result.

Good luck.


On 10.05.2018 15:06, javed khan wrote:
>
> If you can see the image, the output is shown as:
>
> The STUDY 1: used SVM, Partly, RQ7
>                          used SVM, Partly, RQ6
>                          used SVM, Partly, RQ5
>
> For different RQs the SVM and Partly is also repeated. 
>
> The SPARQL query I used is as:
>
> *SELECT * *
>
> *              WHERE { ?x mo:hasRQ ?rq.*
>
> *               ?x mo:hasTitle ?t.   ?x mo:Q.Assess ?ass. ?x mo:hasML
> ?ml.*
>
> *              ?x mo:hasDataset ?ds. ?x mo:hasAccuracyMeasure ?acc*
>
> *               FILTER (rejex(str(?t),'+title+', 'i' )) .*
>
>
> variabe title in last line is a java variable. 
>
>
>
>
> On Tue, May 8, 2018 at 5:16 PM, ajs6f <ajs6f@apache.org
> <ma...@apache.org>> wrote:
>
>     SPARQL normally produces tabular results. What you are showing
>     doesn't fit into any obvious SPARQL results form.
>
>     Please show data, code, expected result and actual result.
>
>     https://stackoverflow.com/help/mcve
>     <https://stackoverflow.com/help/mcve>
>
>     ajs6f
>
>     > On May 8, 2018, at 8:24 AM, javed khan <javedbtk111@gmail.com
>     <ma...@gmail.com>> wrote:
>     >
>     > Hello
>     >
>     > I have a SPARQL query which results a particular study (article)
>     uses
>     > Decision Tree model and NASA, Maxwell, COCOMO datasets.The
>     answer it shows
>     > like for Study 1:
>     >
>     > Decision Tree    NASA
>     > Decision Tree    Maxwell
>     > Decision Tree    COCOMO
>     >
>     > While I need like this:
>     >
>     > Decision Tree  NASA
>     >                        Maxwell
>     >                        COCOMO
>     >
>     >
>     > The subject should not be repeated,kindly if some one could guide?
>     >
>     > Regards
>
>


Re: Repetition of Subject in SPARQL query

Posted by ajs6f <aj...@apache.org>.
We cannot see the image. This list does not accept images. Use gist or pastebin or a similar service to provide information, or cut&paste it.

ajs6f

> On May 10, 2018, at 9:06 AM, javed khan <ja...@gmail.com> wrote:
> 
> 
> 
> If you can see the image, the output is shown as:
> 
> The STUDY 1: used SVM, Partly, RQ7
>                         used SVM, Partly, RQ6
>                         used SVM, Partly, RQ5
> 
> For different RQs the SVM and Partly is also repeated. 
> 
> The SPARQL query I used is as:
> 
> SELECT *
>              WHERE { ?x mo:hasRQ ?rq.
>               ?x mo:hasTitle ?t.   ?x mo:Q.Assess ?ass. ?x mo:hasML ?ml.
>              ?x mo:hasDataset ?ds. ?x mo:hasAccuracyMeasure ?acc
>               FILTER (rejex(str(?t),'+title+', 'i' )) .
> 
> variabe title in last line is a java variable. 
> 
> 
> 
> 
> On Tue, May 8, 2018 at 5:16 PM, ajs6f <aj...@apache.org> wrote:
> SPARQL normally produces tabular results. What you are showing doesn't fit into any obvious SPARQL results form.
> 
> Please show data, code, expected result and actual result.
> 
> https://stackoverflow.com/help/mcve
> 
> ajs6f
> 
>> On May 8, 2018, at 8:24 AM, javed khan <ja...@gmail.com> wrote:
>> 
>> Hello
>> 
>> I have a SPARQL query which results a particular study (article) uses
>> Decision Tree model and NASA, Maxwell, COCOMO datasets.The answer it shows
>> like for Study 1:
>> 
>> Decision Tree    NASA
>> Decision Tree    Maxwell
>> Decision Tree    COCOMO
>> 
>> While I need like this:
>> 
>> Decision Tree  NASA
>>                       Maxwell
>>                       COCOMO
>> 
>> 
>> The subject should not be repeated,kindly if some one could guide?
>> 
>> Regards
> 
> 


Re: Repetition of Subject in SPARQL query

Posted by javed khan <ja...@gmail.com>.
If you can see the image, the output is shown as:

The STUDY 1: used SVM, Partly, RQ7
                         used SVM, Partly, RQ6
                         used SVM, Partly, RQ5

For different RQs the SVM and Partly is also repeated.

The SPARQL query I used is as:

*SELECT * *

*              WHERE { ?x mo:hasRQ ?rq.*

*               ?x mo:hasTitle ?t.   ?x mo:Q.Assess ?ass. ?x mo:hasML ?ml.*

*              ?x mo:hasDataset ?ds. ?x mo:hasAccuracyMeasure ?acc*

*               FILTER (rejex(str(?t),'+title+', 'i' )) .*

variabe title in last line is a java variable.




On Tue, May 8, 2018 at 5:16 PM, ajs6f <aj...@apache.org> wrote:

> SPARQL normally produces tabular results. What you are showing doesn't fit
> into any obvious SPARQL results form.
>
> Please show data, code, expected result and actual result.
>
> https://stackoverflow.com/help/mcve
>
> ajs6f
>
> > On May 8, 2018, at 8:24 AM, javed khan <ja...@gmail.com> wrote:
> >
> > Hello
> >
> > I have a SPARQL query which results a particular study (article) uses
> > Decision Tree model and NASA, Maxwell, COCOMO datasets.The answer it
> shows
> > like for Study 1:
> >
> > Decision Tree    NASA
> > Decision Tree    Maxwell
> > Decision Tree    COCOMO
> >
> > While I need like this:
> >
> > Decision Tree  NASA
> >                        Maxwell
> >                        COCOMO
> >
> >
> > The subject should not be repeated,kindly if some one could guide?
> >
> > Regards
>
>

Re: Repetition of Subject in SPARQL query

Posted by ajs6f <aj...@apache.org>.
SPARQL normally produces tabular results. What you are showing doesn't fit into any obvious SPARQL results form.

Please show data, code, expected result and actual result.

https://stackoverflow.com/help/mcve

ajs6f

> On May 8, 2018, at 8:24 AM, javed khan <ja...@gmail.com> wrote:
> 
> Hello
> 
> I have a SPARQL query which results a particular study (article) uses
> Decision Tree model and NASA, Maxwell, COCOMO datasets.The answer it shows
> like for Study 1:
> 
> Decision Tree    NASA
> Decision Tree    Maxwell
> Decision Tree    COCOMO
> 
> While I need like this:
> 
> Decision Tree  NASA
>                        Maxwell
>                        COCOMO
> 
> 
> The subject should not be repeated,kindly if some one could guide?
> 
> Regards