You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Bob DuCharme <bo...@snee.com> on 2022/01/24 23:04:49 UTC

Trying to count the properties used for each class

Using arq and the data at 
http://www.snee.com/bobdc.blog/files/BeatlesMusicians.ttl, I’m trying to 
write a query that will list the classes used in the data and the number 
of distinct properties used by instances of that class. I’m having a 
hard time and can’t even write a query that lists the number of 
properties used for just one of the classes; the following just shows me 
a series of ones.

    SELECT (COUNT(DISTINCT ?p) AS ?pcount)
    WHERE {
       ?s a <http://learningsparql.com/ns/schema/Song> .
       ?s ?p ?o .
    }
    GROUP BY ?p

Any suggestions?

Thanks,

Bob


Re: Trying to count the properties used for each class

Posted by Bob DuCharme <bo...@snee.com>.
Thank you Martyna and Nicola. Both queries worked perfectly!

Bob


On 1/24/22 6:21 PM, Nicola Vitucci wrote:
> Hey Bob,
>
> does this one do what you're after?
>
> SELECT DISTINCT ?cl (COUNT(DISTINCT ?p) AS ?c)
> WHERE {
>    ?s a ?cl .
>    ?s ?p ?o .
> }
> GROUP BY ?cl
>
> Nicola
>
> Il giorno lun 24 gen 2022 alle ore 23:05 Bob DuCharme <bo...@snee.com> ha
> scritto:
>
>> Using arq and the data at
>> http://www.snee.com/bobdc.blog/files/BeatlesMusicians.ttl, I’m trying to
>> write a query that will list the classes used in the data and the number
>> of distinct properties used by instances of that class. I’m having a
>> hard time and can’t even write a query that lists the number of
>> properties used for just one of the classes; the following just shows me
>> a series of ones.
>>
>>      SELECT (COUNT(DISTINCT ?p) AS ?pcount)
>>      WHERE {
>>         ?s a <http://learningsparql.com/ns/schema/Song> .
>>         ?s ?p ?o .
>>      }
>>      GROUP BY ?p
>>
>> Any suggestions?
>>
>> Thanks,
>>
>> Bob
>>
>>

Re: Trying to count the properties used for each class

Posted by Nicola Vitucci <ni...@gmail.com>.
Thanks Alasdair,

This looks really useful. I haven't seen this query though - have I missed
it or were you not specifically referring to this?

Nicola


Il mar 25 gen 2022, 10:21 Gray, Alasdair <A....@hw.ac.uk.invalid> ha
scritto:

> We defined a lot of useful statistics queries for datasets in §6.6 of the
> W3C HCLS Dataset Description Guidelines
> https://www.w3.org/TR/hcls-dataset/#s6_6
>
> I’ve made these available in a GitHub repo
> https://github.com/AlasdairGray/HCLS-Stats-Queries
>
> Hopefully you find these helpful
>
> Alasdair
> --
> Alasdair J G Gray
> Associate Professor in Computer Science,
> School of Mathematical and Computer Sciences
> Heriot-Watt University, Edinburgh, UK.
>
> Email: A.J.G.Gray@hw.ac.uk<ma...@hw.ac.uk>
> Web: http://www.macs.hw.ac.uk/~ajg33
> ORCID: http://orcid.org/0000-0002-5711-4872
> Office: Earl Mountbatten Building 1.39
> Twitter: @gray_alasdair
>
>
> Heriot-Watt is a global University, as a result my working hours may not
> be your working hours. Do not feel pressure to reply to this email outside
> your working hours.
>
>
> To arrange a meeting:
> https://outlook.office365.com/owa/calendar/AlasdairGray@heriotwatt.onmicrosoft.com/bookings/
>
> From: Nicola Vitucci <ni...@gmail.com>
> Date: Monday, 24 January 2022 at 23:21
> To: users@jena.apache.org <us...@jena.apache.org>
> Subject: Re: Trying to count the properties used for each class
> ****************************************************************
> Caution: This email originated from a sender outside Heriot-Watt
> University.
> Do not follow links or open attachments if you doubt the authenticity of
> the sender or the content.
> ****************************************************************
>
>
> Hey Bob,
>
> does this one do what you're after?
>
> SELECT DISTINCT ?cl (COUNT(DISTINCT ?p) AS ?c)
> WHERE {
>   ?s a ?cl .
>   ?s ?p ?o .
> }
> GROUP BY ?cl
>
> Nicola
>
> Il giorno lun 24 gen 2022 alle ore 23:05 Bob DuCharme <bo...@snee.com> ha
> scritto:
>
> > Using arq and the data at
> > http://www.snee.com/bobdc.blog/files/BeatlesMusicians.ttl, I’m trying to
> > write a query that will list the classes used in the data and the number
> > of distinct properties used by instances of that class. I’m having a
> > hard time and can’t even write a query that lists the number of
> > properties used for just one of the classes; the following just shows me
> > a series of ones.
> >
> >     SELECT (COUNT(DISTINCT ?p) AS ?pcount)
> >     WHERE {
> >        ?s a <http://learningsparql.com/ns/schema/Song> .
> >        ?s ?p ?o .
> >     }
> >     GROUP BY ?p
> >
> > Any suggestions?
> >
> > Thanks,
> >
> > Bob
> >
> >
> ________________________________
>
> Founded in 1821, Heriot-Watt is a leader in ideas and solutions. With
> campuses and students across the entire globe we span the world, delivering
> innovation and educational excellence in business, engineering, design and
> the physical, social and life sciences. This email is generated from the
> Heriot-Watt University Group, which includes:
>
>   1.  Heriot-Watt University, a Scottish charity registered under number
> SC000278
>   2.  Heriot- Watt Services Limited (Oriam), Scotland's national
> performance centre for sport. Heriot-Watt Services Limited is a private
> limited company registered is Scotland with registered number SC271030 and
> registered office at Research & Enterprise Services Heriot-Watt University,
> Riccarton, Edinburgh, EH14 4AS.
>
> The contents (including any attachments) are confidential. If you are not
> the intended recipient of this e-mail, any disclosure, copying,
> distribution or use of its contents is strictly prohibited, and you should
> please notify the sender immediately and then delete it (including any
> attachments) from your system.
>

Re: Trying to count the properties used for each class

Posted by "Gray, Alasdair" <A....@hw.ac.uk.INVALID>.
We defined a lot of useful statistics queries for datasets in §6.6 of the W3C HCLS Dataset Description Guidelines
https://www.w3.org/TR/hcls-dataset/#s6_6

I’ve made these available in a GitHub repo
https://github.com/AlasdairGray/HCLS-Stats-Queries

Hopefully you find these helpful

Alasdair
--
Alasdair J G Gray
Associate Professor in Computer Science,
School of Mathematical and Computer Sciences
Heriot-Watt University, Edinburgh, UK.

Email: A.J.G.Gray@hw.ac.uk<ma...@hw.ac.uk>
Web: http://www.macs.hw.ac.uk/~ajg33
ORCID: http://orcid.org/0000-0002-5711-4872
Office: Earl Mountbatten Building 1.39
Twitter: @gray_alasdair


Heriot-Watt is a global University, as a result my working hours may not be your working hours. Do not feel pressure to reply to this email outside your working hours.


To arrange a meeting: https://outlook.office365.com/owa/calendar/AlasdairGray@heriotwatt.onmicrosoft.com/bookings/

From: Nicola Vitucci <ni...@gmail.com>
Date: Monday, 24 January 2022 at 23:21
To: users@jena.apache.org <us...@jena.apache.org>
Subject: Re: Trying to count the properties used for each class
****************************************************************
Caution: This email originated from a sender outside Heriot-Watt University.
Do not follow links or open attachments if you doubt the authenticity of the sender or the content.
****************************************************************


Hey Bob,

does this one do what you're after?

SELECT DISTINCT ?cl (COUNT(DISTINCT ?p) AS ?c)
WHERE {
  ?s a ?cl .
  ?s ?p ?o .
}
GROUP BY ?cl

Nicola

Il giorno lun 24 gen 2022 alle ore 23:05 Bob DuCharme <bo...@snee.com> ha
scritto:

> Using arq and the data at
> http://www.snee.com/bobdc.blog/files/BeatlesMusicians.ttl, I’m trying to
> write a query that will list the classes used in the data and the number
> of distinct properties used by instances of that class. I’m having a
> hard time and can’t even write a query that lists the number of
> properties used for just one of the classes; the following just shows me
> a series of ones.
>
>     SELECT (COUNT(DISTINCT ?p) AS ?pcount)
>     WHERE {
>        ?s a <http://learningsparql.com/ns/schema/Song> .
>        ?s ?p ?o .
>     }
>     GROUP BY ?p
>
> Any suggestions?
>
> Thanks,
>
> Bob
>
>
________________________________

Founded in 1821, Heriot-Watt is a leader in ideas and solutions. With campuses and students across the entire globe we span the world, delivering innovation and educational excellence in business, engineering, design and the physical, social and life sciences. This email is generated from the Heriot-Watt University Group, which includes:

  1.  Heriot-Watt University, a Scottish charity registered under number SC000278
  2.  Heriot- Watt Services Limited (Oriam), Scotland's national performance centre for sport. Heriot-Watt Services Limited is a private limited company registered is Scotland with registered number SC271030 and registered office at Research & Enterprise Services Heriot-Watt University, Riccarton, Edinburgh, EH14 4AS.

The contents (including any attachments) are confidential. If you are not the intended recipient of this e-mail, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete it (including any attachments) from your system.

Re: Trying to count the properties used for each class

Posted by Nicola Vitucci <ni...@gmail.com>.
Hey Bob,

does this one do what you're after?

SELECT DISTINCT ?cl (COUNT(DISTINCT ?p) AS ?c)
WHERE {
  ?s a ?cl .
  ?s ?p ?o .
}
GROUP BY ?cl

Nicola

Il giorno lun 24 gen 2022 alle ore 23:05 Bob DuCharme <bo...@snee.com> ha
scritto:

> Using arq and the data at
> http://www.snee.com/bobdc.blog/files/BeatlesMusicians.ttl, I’m trying to
> write a query that will list the classes used in the data and the number
> of distinct properties used by instances of that class. I’m having a
> hard time and can’t even write a query that lists the number of
> properties used for just one of the classes; the following just shows me
> a series of ones.
>
>     SELECT (COUNT(DISTINCT ?p) AS ?pcount)
>     WHERE {
>        ?s a <http://learningsparql.com/ns/schema/Song> .
>        ?s ?p ?o .
>     }
>     GROUP BY ?p
>
> Any suggestions?
>
> Thanks,
>
> Bob
>
>

Re: Trying to count the properties used for each class

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
You're counting the same thing you're grouping by. I think you need:

    SELECT ?c (COUNT(DISTINCT ?p) AS ?pcount)
    WHERE {
       ?s a ?c .
       ?s ?p ?o .
    }
    GROUP BY ?c

http://sparql.org/sparql?query=++++SELECT+%3Fc+%28COUNT%28DISTINCT+%3Fp%29+AS+%3Fpcount%29%0D%0A++++WHERE+%7B%0D%0A+++++++%3Fs+a+%3Fc+.%0D%0A+++++++%3Fs+%3Fp+%3Fo+.%0D%0A++++%7D%0D%0A++++GROUP+BY+%3Fc&default-graph-uri=http%3A%2F%2Fwww.snee.com%2Fbobdc.blog%2Ffiles%2FBeatlesMusicians.ttl&output=text&stylesheet=%2Fxml-to-html.xsl

On Tue, Jan 25, 2022 at 12:05 AM Bob DuCharme <bo...@snee.com> wrote:
>
> Using arq and the data at
> http://www.snee.com/bobdc.blog/files/BeatlesMusicians.ttl, I’m trying to
> write a query that will list the classes used in the data and the number
> of distinct properties used by instances of that class. I’m having a
> hard time and can’t even write a query that lists the number of
> properties used for just one of the classes; the following just shows me
> a series of ones.
>
>     SELECT (COUNT(DISTINCT ?p) AS ?pcount)
>     WHERE {
>        ?s a <http://learningsparql.com/ns/schema/Song> .
>        ?s ?p ?o .
>     }
>     GROUP BY ?p
>
> Any suggestions?
>
> Thanks,
>
> Bob
>