SHACL function

18 views
Skip to first unread message

Emily Zhang

unread,
Oct 18, 2020, 3:53:48 PM10/18/20
to TopBraid Suite Users
Hi all,
This is a simple question regarding SHACL functions in TBCME. Apologize for posting it here, I didn't find any other places to discuss this. Please point me to it if you know any place like "StackOverflow" for SHACL. 
Based on my previous question, I trying to build a validation rule to identify the possible disease type of patients. My current rule is: if the subject has any of the features A, B, C, AND it doesn't have feature D. Then the subject could be predicted as having object X. I am using the function "sh:in" to include the feature A, B, C. However, I am stuck at the place of how to present the negative presence of feature D. I've tried to search for all the SHACL rule on W3C, and here is one I found that could be relevant.
        sh:property [
                sh:path ex:bCode ;
                sh:pattern "D" ;    
                sh:flags "i" ;       # Ignore case
        ] .
I use the string from feature D as the pattern to ignore. However, it doesn't work. The subject with feature D was still be predicted as subject X. 
Was I on the wrong track? What's a more accurate SHACL function to define the non-presence of a feature? The feature I am talking about here is the Nodeshape under properties. 
Thanks a lot,
Emily

Irene Polikoff

unread,
Oct 18, 2020, 11:37:36 PM10/18/20
to topbrai...@googlegroups.com
https://www.w3.org/TR/shacl/#NotConstraintComponent

However, if this is about values of the same property e.g., ex:feature and you are already using sh:in A, B, C, you do not need any other constraints. Sh:in says that values of ex:feature must be either A, B or C and nothing else. Thus, you don’t need a separate constraint to say that values of ex:feature can’t be D.

If this is about two different properties, then, for the second property, use sh:not with sh:hasValue. E.g., ex:feature must be A, B or C is stated using sh:in AND ex:diagnosis can not be D is stated using sh:not and sh:hasValue.

If you want to say that at least one of the values has to be A, B or C, but there can’t be other values, do not use sh:in. Instead use https://www.w3.org/TR/shacl/#HasValueConstraintComponent with https://www.w3.org/TR/shacl/#OrConstraintComponent.

sh:or (
[
sh:path ex:feature ;
sh:hasValue ex:A ;
]
[
sh:path ex:feature ;
sh:hasValue ex:B ;
]
[
sh:path ex:feature ;
sh:hasValue ex:C ;
]
)

sh:not [
sh:path ex:feature ;
sh:hasValue ex:D ;
]
> --
> 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/64d2ec6c-c3d9-4b96-9550-9551241c7af1n%40googlegroups.com.

Zhang

unread,
Oct 18, 2020, 11:40:23 PM10/18/20
to topbrai...@googlegroups.com
Thank you so much, Irene! I really appreciate it a lot! This is super helpful.
> To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/5586EA43-7F32-4052-8A35-5AFDA24242E4%40topquadrant.com.

Reply all
Reply to author
Forward
0 new messages