Add, extend and refactor SPARQL queries #767
Open
+1,523
−444
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR extends the Search Links area of the documentation by adding and extending SPARQL queries. It also refactors some of the existing queries.
I'm proposing to change the variable templating pattern a little, so that the examples are natively valid SPARQL but can also be used as string templates in code. This is done by using the
$character for variables which can be templated, which according to 4.1.3 Syntax for Query Variables in SPARQL 1.1 Query Language is as equally valid as?. For example, instead of:I propose...
... or potentially if we prefer the
BINDas an entrypoint...... so that the query can be executed as is, validated, linted, or constrained by replacing the template variable. In Python, for example:
Other languages could use a regular expression like
(\$\w+).Aside from these changes to the templating pattern, this PR also provides queries in an ontologically symmetrical form. Thus both the direct and inverse properties are tested, with
UNIONpreferred overOPTIONALfor performance reasons.I would like to consider with the community whether this symmetry is always necessary. I think it is useful for querying knowledge graphs which implement both the Linked Art Model and API document partitions (because part/whole and member/has_member are documented patterns), but is it perhaps going too far by testing the inverse of pure CRM patterns that Linked Art doesn't describe? For example,
crm:P98_brought_into_lifeisn't a documented Linked Art property:A further question here is whether or not the inverse properties should be provided in the query explicitly, or whether instead the ontologies (CRM, LA, SKOS, etc.) should be side-loaded and inferred against.
Relates to #763.