Feedback on tosh:values

28 views
Skip to first unread message

Tim Smith

unread,
Aug 15, 2022, 10:38:56 AM8/15/22
to topbrai...@googlegroups.com
I am finding the use of inferred properties to be very valuable. Using tosh:values in SPARQL to retrieve inferred values works well.  

If I had a choice, I would prefer the second option (see below in bold) which doesn't require tosh:values.   Using tosh:values means the user must know the property they are querying is an inferred property and that is not obvious without looking at the property shape.  I think understanding complex property shapes is a level of knowledge above a user that can write a SPARQL query.

Tim



Use of Inferred Values using SPARQL

TopBraid includes a magic property (aka property function) tosh:values that can be used to fetch inferred values, or to check whether a given focus node has certain inferred values for a given predicate. Here is an example query:

SELECT *
WHERE {
	?person a schema:Person .
	(?person schema:age) tosh:values ?age .
}

Note that this magic property can only be used to derive the right-hand value from the left-hand values, not vice versa. So the caller needs to make sure that both variables on the left-hand side are bound when tosh:values is evaluated. This magic property makes property value rules available to any SPARQL-based technology in the TopBraid platform, including SWP, SPARQLMotion, SPIN and SHACL-SPARQL itself.

tosh:values falls back to any declared sh:defaultValue if no other value exists for the focus node and predicate.

We are currently evaluating whether this integration with SPARQL should also more directly work with every use of an inferred property in a SPARQL query. For example, the following would then also work:

SELECT *
WHERE {
	?person a schema:Person .
	?person schema:age ?age .
}

We welcome feedback on whether TopBraid should support this syntax in SPARQL or whether tosh:values is sufficient.





Holger Knublauch

unread,
Aug 16, 2022, 9:35:06 AM8/16/22
to topbrai...@googlegroups.com
Hi Tim,

the reason why my own suggestion from the article that you mention is not implemented is that it's tricky. The difficult bit is that in SPARQL each BGP works somewhat out-of-context. For example when ?person schema:age ?age is evaluated and ?person is bound, the query engine cannot really know that ?person is an instance of schema:Person unless it looks at previous lines in the query execution. The values rules are defined per-class and don't apply globally. So to implement what you are asking for we would need to initialize the SPARQL query graph with dedicated magic that knows that schema:age may have a sh:values rule, and evaluate it whenever the subject is indeed an instance of schema:Person. That test alone can be quite expensive, and overall the whole query would run slower.

This works better in context-sensitive languages like GraphQL and ADS/JavaScript. In those languages we know from the context of the subject that we are inside of a Person query and can then very quickly determine the age. For example in ADS it would just look like person.age and it would do the computation automatically. ADS can handle everything that SPARQL can and may potentially be an alternative.

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/CAF0WbnJJsGDcLLpwa1g53P12AB0vYC9CGCSYj_mgCt6u_xS36g%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages