help with counting things in SHACL

16 views
Skip to first unread message

cbur...@healthwise.org

unread,
Apr 26, 2023, 12:54:31 PM4/26/23
to TopBraid Suite Users
So I have written a few sh:values rules that count how many values of particular property shapes exist in a graph:

Screenshot 2023-04-26 094626.jpg

These are all powered by simple sh:values statements, like this:

  sh:values [
      sh:count [
          sh:path enterprise_schemas:whatIs ;
        ] ;
    ] ;

Now I want to count how many of those property shapes are currently returning "0" as a value -- in this example, the expected count would be 1 -- and return that as the value of an additional property shape, ex:gapCount.

Can we do this with SHACL? It seems like it should be possible. I've played around with various combinations of sh:count, sh:alternativePath, and so on, but haven't hit upon a way that works and would love some advice.

Carl

Holger Knublauch

unread,
Apr 26, 2023, 1:04:59 PM4/26/23
to topbrai...@googlegroups.com
Yes, sh:values rules can access other properties that are also computed via sh:values. But for this to work, you are limited to using

sh:path ex:someInferredProperty

no path expressions like alternativePath will work for those. I guess you could try to express this via https://w3c.github.io/shacl/shacl-af/#union

Holger


On 26 Apr 2023, at 5:54 pm, cbur...@healthwise.org <cbur...@healthwise.org> wrote:

So I have written a few sh:values rules that count how many values of particular property shapes exist in a graph:

<Screenshot 2023-04-26 094626.jpg>

These are all powered by simple sh:values statements, like this:

  sh:values [
      sh:count [
          sh:path enterprise_schemas:whatIs ;
        ] ;
    ] ;

Now I want to count how many of those property shapes are currently returning "0" as a value -- in this example, the expected count would be 1 -- and return that as the value of an additional property shape, ex:gapCount.

Can we do this with SHACL? It seems like it should be possible. I've played around with various combinations of sh:count, sh:alternativePath, and so on, but haven't hit upon a way that works and would love some advice.

Carl


--
The topics of this mailing list include TopBraid EDG and related technologies such as SHACL.
To post to this group, send email to topbrai...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/2e4d286a-4d79-4abd-ae9c-5c9e456c4130n%40googlegroups.com.
<Screenshot 2023-04-26 094626.jpg>

Reply all
Reply to author
Forward
0 new messages