Help Writing Inferences

36 views
Skip to first unread message

GaBriella Branson

unread,
Nov 28, 2022, 8:02:19 PM11/28/22
to TopBraid Suite Users
Hello,

I have a series of 10 boolean attributes. I would like "true" to be inferred if another property has a value.

As an example
if systemOwner has any value, then sponsoredInvestment is true

An additional example
if hostedOn matches NIFC eNet or Denver Federal Center or WRCC, then enterpriseArchitectureSupportedDevelopmentEnvironment is true, but if hostedOn is AWS or Desktop or ESRI Cloud or null, then enterpriseArchitectureSupportedDevelopmentEnvironment is false

Is this a legitimate use of inferrencing or should I handle this a different way?

Do you have any recommendations on courses or resources I can use to write these?

Thanks in advance!

Holger Knublauch

unread,
Nov 29, 2022, 4:11:38 AM11/29/22
to topbrai...@googlegroups.com
Hi GaBriella,

you can use SHACL Advanced Features to infer values. For your use cases, sh:values rules sound like a good match.


In your case, maybe this helps:

ex:MyClass
    a owl:Class, sh:NodeShape ;
    sh:property ex:MyClass-sponsoredInvestment ;
.

ex:MyClass-sponsoredInvestment
    a sh:PropertyShape ;
    sh:path ex:sponsoredInvestment ;
    sh:datatype xsd:boolean ;
    sh:values [
        sh:exists [
            sh:path ex:systemOwner ;
        ] ;
    ]
.

This would mark "sponsoredInvestment" as a read-only property that will be automatically computed when displayed and queried, esp on forms, through GraphQL and through JavaScript/ADS.

Such sh:values rules can also be expressed in SPARQL or JavaScript/ADS.

Feel free to post your follow-up questions if you need more instructions.

Holger



--
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/0cdd2f9d-85dc-43e9-ac81-5f6382513f28n%40googlegroups.com.

Branson, GaBriella C

unread,
Nov 29, 2022, 7:21:51 PM11/29/22
to topbrai...@googlegroups.com

Hi Holger,

 

Thank you for the link and sample code.

 

I’ve tried several variations and am doing something wrong. Here is the latest:

 

wftech:AuthoritativeDataSourceDeclarationView

    a sh:NodeShape ;

    sh:property wftech:AuthoritativeSourceDeclarationView-sponsoredInvestment ;

.

 

wftech:AuthoritativeSourceDeclarationView-sponsoredInvestment

    a sh:PropertyShape ;

    sh:path wftech:sponsoredInvestment ;

    sh:datatype xsd:boolean ;

    sh:values [

        sh:exists [

            sh:path wftech:systemOwner ;

        ] ;

    ]

.

 

wftech = my prefix

AuthoritativeDataSourceDeclarationView = the node shape

 

 

And this is the error I get: (I tried to compare what I had done versus your sample to ensure I had all the correct punctuation and I didn’t notice any missing, but it sure seems to think it wants some more semi-colons )

 

I took out owl:class because my type is only a node shape.

 

 

Perhaps I need to schedule a call and use support hours?

 

GaBriella Branson

Wildland Fire Data Management Program - Knowledge Manager

 

Stay Connected! Sign up to receive  email updates from the Wildland Fire Data Management Program

 

From: topbrai...@googlegroups.com <topbrai...@googlegroups.com> On Behalf Of Holger Knublauch
Sent: Tuesday, November 29, 2022 12:11 AM
To: topbrai...@googlegroups.com
Subject: [EXTERNAL] Re: [topbraid-users] Help Writing Inferences

 

 

 This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.  

 

Holger Knublauch

unread,
Nov 30, 2022, 4:42:14 AM11/30/22
to topbrai...@googlegroups.com
Hi GaBriella,

the example that I had sent in my email was in Turtle notation, which you can edit on the Source Code tab of TopBraid EDG.

To enter the sh:values rule, select the property shape and switch to the Source Code panel. Then paste the sh:values snippet so that it looks as follows:

wftech:AuthoritativeDataSourceDeclarationView-sponsoredInvestment
  a sh:PropertyShape ;
  sh:path wftech:sponsoredInvestment ;
  sh:datatype xsd:boolean ;
  sh:maxCount 1 ;
  sh:name "sponsored investment" ;
  sh:values [
      sh:exists [
          sh:path wftech:systemOwner ;
        ] ;
    ] ;
.

It will then display like this on the form:

PastedGraphic-1.png

We do not have a dedicated editor for such sh:values rules in SHACL node expression syntax, so Source Code is the only option.

From the error message that you mention, it seems you have pasted the source code into the default editor for sh:values that shows up on the form. That is however expecting JavaScript source code, not Turtle. If you want to use JavaScript instead of the SHACL syntax above, you can paste the following:

PastedGraphic-2.png

which would be another way of deriving the boolean for the case that the systemOwner property has any value. If you want to use the example above, also go the Home asset of your Ontology and switch to the Script API tab, then enter wftech as shown:

PastedGraphic-3.png

This makes sure that the wftech constant is known to the JavaScript API. You may need to press refresh on the Script Editor panel to activate that.

HTH
Holger



On 30 Nov 2022, at 12:21 am, 'Branson, GaBriella C' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

Hi Holger,
 
Thank you for the link and sample code.
 
I’ve tried several variations and am doing something wrong. Here is the latest:
 
wftech:AuthoritativeDataSourceDeclarationView
    a sh:NodeShape ;
    sh:property wftech:AuthoritativeSourceDeclarationView-sponsoredInvestment ;
.
 
wftech:AuthoritativeSourceDeclarationView-sponsoredInvestment
    a sh:PropertyShape ;
    sh:path wftech:sponsoredInvestment ;
    sh:datatype xsd:boolean ;
    sh:values [
        sh:exists [
            sh:path wftech:systemOwner ;
        ] ;
    ]
.
 
wftech = my prefix
AuthoritativeDataSourceDeclarationView = the node shape
 
 
And this is the error I get: (I tried to compare what I had done versus your sample to ensure I had all the correct punctuation and I didn’t notice any missing, but it sure seems to think it wants some more semi-colons )
<image003.png>
 
I took out owl:class because my type is only a node shape.
 
<image001.png>
 
Perhaps I need to schedule a call and use support hours?
 
GaBriella Branson
Wildland Fire Data Management Program - Knowledge Manager
 
<image002.png>

Holger Knublauch

unread,
Nov 30, 2022, 4:54:03 AM11/30/22
to topbrai...@googlegroups.com
For the record I am also attaching the whole example (using the JavaScript solution).

wftech.ttl
PastedGraphic-1.png

Holger Knublauch

unread,
Dec 2, 2022, 5:01:43 AM12/2/22
to topbrai...@googlegroups.com
On 30 Nov 2022, at 9:53 am, Holger Knublauch <hol...@topquadrant.com> wrote:

For the record I am also attaching the whole example (using the JavaScript solution).

<wftech.ttl>

and here is the proof that it works in principle:

<PastedGraphic-1.png>

Holger


On 30 Nov 2022, at 9:41 am, Holger Knublauch <hol...@topquadrant.com> wrote:

Hi GaBriella,

the example that I had sent in my email was in Turtle notation, which you can edit on the Source Code tab of TopBraid EDG.

To enter the sh:values rule, select the property shape and switch to the Source Code panel. Then paste the sh:values snippet so that it looks as follows:

wftech:AuthoritativeDataSourceDeclarationView-sponsoredInvestment
  a sh:PropertyShape ;
  sh:path wftech:sponsoredInvestment ;
  sh:datatype xsd:boolean ;
  sh:maxCount 1 ;
  sh:name "sponsored investment" ;
  sh:values [
      sh:exists [
          sh:path wftech:systemOwner ;
        ] ;
    ] ;
.

It will then display like this on the form:

<PastedGraphic-1.png>

We do not have a dedicated editor for such sh:values rules in SHACL node expression syntax, so Source Code is the only option.

From the error message that you mention, it seems you have pasted the source code into the default editor for sh:values that shows up on the form. That is however expecting JavaScript source code, not Turtle. If you want to use JavaScript instead of the SHACL syntax above, you can paste the following:

<PastedGraphic-2.png>

which would be another way of deriving the boolean for the case that the systemOwner property has any value. If you want to use the example above, also go the Home asset of your Ontology and switch to the Script API tab, then enter wftech as shown:

Branson, GaBriella C

unread,
Dec 7, 2022, 3:03:23 PM12/7/22
to topbrai...@googlegroups.com

Thank you, Holger! I appreciate your assistance.

 

GaBriella Branson

Wildland Fire Data Management Program - Knowledge Manager

 

Stay Connected! Sign up to receive  email updates from the Wildland Fire Data Management Program

Reply all
Reply to author
Forward
0 new messages