You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is sometimes used a pattern to use a bind to simulate a constant, for example see https://en.wikibooks.org/wiki/SPARQL/Templates on a Wikidata feature (even if the Wikidata feature is a bit of scope here as only items can be bound)
It can also be used to allow to change easily the language we want the labels for in a query
You can change the language of the labels by just changing the bound values. The issue here is that qlever does not propagates the constant and do not optimize the language filters at all, this makes the pattern unusable in some cases.
Could some sort of constant propagation be implemented in the query analysis to support this ?
A follow up question will be posted as first comment because related but is a separate discussion.
The text was updated successfully, but these errors were encountered:
as something like
…
{
bind(?lang as "de")
?item rdfs:label ?itemLabel filter (lang(?itemLabel) = "de")
} union {
bind(?lang as "en")
?item rdfs:label ?itemLabel filter (lang(?itemLabel) = "en")
}
…
could be a step to help implement what the Wikibase query service does to retrieve labels in several languages efficiently. It does not solves prioritizing chosing the labels however if we want only one language.
I don't think there is currently something to easily do this last part in pure SPARQL generally, however. A "coalesce" could do this if we name the variables differently
bind (coalesce(?itemLabelDe, ?itemLabelEn) as ?itemLabel)
but my proposition does not rewrite to create variables.
An alternative could be using a group function, like a custom "max" or "min" function which the order is selected
select ?item (min(?itemLabel)) {
…
} group by ?itemLabel ?lang order by asc/desc rank(?lang, "en", "de")
where "rank" is a function that returns the number of the first equal parameter ( 1 for rank("en", "en", "de"), 2 for rank("de", "en", "de") …)
Still quite cumbersome however, needs a group by. Just thoughts.
It is sometimes used a pattern to use a bind to simulate a constant, for example see https://en.wikibooks.org/wiki/SPARQL/Templates on a Wikidata feature (even if the Wikidata feature is a bit of scope here as only items can be bound)
It can also be used to allow to change easily the language we want the labels for in a query
Select ?item ?itemLabel ?type ?typeLabel {
bind ("en" as ?lang)
?item rdfs:label ?itemLabel ;
wdt:P31 ?type .
?type rdfs:label ?typeLabel filter (lang (?typeLabel) = ?lang).
filter (lang (?langLabel) = ?langLabel).
}
You can change the language of the labels by just changing the bound values. The issue here is that qlever does not propagates the constant and do not optimize the language filters at all, this makes the pattern unusable in some cases.
Could some sort of constant propagation be implemented in the query analysis to support this ?
A follow up question will be posted as first comment because related but is a separate discussion.
The text was updated successfully, but these errors were encountered: