Country -> Region Inference in EDG

22 views
Skip to first unread message

Fan Li

unread,
Jul 28, 2022, 7:29:23 AM7/28/22
to TopBraid Suite Users
Sorry if this is a trivial question. I am picking up SHACL inference in EDG again. We'd like users to select a country (e.g. United States) and automatically infer the region it belongs to (e.g. North America). How to accomplish this in EDG? Thanks!

Holger Knublauch

unread,
Jul 28, 2022, 8:54:37 AM7/28/22
to topbrai...@googlegroups.com
Hi Fan Li,

What would be the formula (in prose) to infer the region from a country? If that info is already stored as a triple such as ex:USA ex:region ex:NorthAmerica then you wouldn’t need an inference. But without such triples, where would the sh:values rule look up that knowledge?

Holger


On 28 Jul 2022, at 7:29 am, Fan Li <lifa...@gmail.com> wrote:

Sorry if this is a trivial question. I am picking up SHACL inference in EDG again. We'd like users to select a country (e.g. United States) and automatically infer the region it belongs to (e.g. North America). How to accomplish this in EDG? Thanks!

--
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/049f1b19-1fa5-4261-a21f-470b9aa4488dn%40googlegroups.com.

Fan Li

unread,
Jul 28, 2022, 10:04:25 AM7/28/22
to TopBraid Suite Users
Hi Holger, thanks for your reply. In this case, the two attributes may be linked by an existing triple (ex:USA ex:region ex:NorthAmerica). In other cases, they may be linked by some SHACL property value rule or custom SPARQL query.

My question is when a user enters value in one attribute, how can we automatically populate the other attribute in the user interface? Do I just need to set "sh:values" for the 2nd attribute? Could you please provide an example?

Holger Knublauch

unread,
Jul 28, 2022, 11:39:30 AM7/28/22
to topbrai...@googlegroups.com
Ok, let’s assume the simple case for now, where we have ex:USA ex:region ex:NorthAmerica. Then let’s assume we have an ex:Address class with properties ex:country and ex:inferredRegion. Once the user selects USA and saves changes, the inferred value should show up:

ex:Address
    a owl:Class, sh:NodeShape ;
    sh:property ex:Address-country ;
    sh:property ex:Address-inferredRegion ;

ex:Address-inferredRegion
    a sh:PropertyShape ;
    sh:path ex:inferredRegion ;
    sh:values [
        sh:path ( ex:country ex:region ) ;
    ] .

The design above uses a path expression (SHACL node expression) that gets the asserted region of the asserted country. The complete syntax of such node expressions is defined in https://w3c.github.io/shacl/shacl-af/#node-expressions

If you need something more complex, you can define sh:values rules using JavaScript/ADS or SPARQL. When you enter sh:values rules on the form, the system actually suggests to use JavaScript. To enter SPARQL, the syntax would be like

sh:values [
    sh:select “””
        PREFIX ex: ...
        SELECT ?region
        WHERE {
            $this ex:country / ex:region ?region .
        } “”” ;
]

HTH
Holger
 

Reply all
Reply to author
Forward
0 new messages