Closed lvaudor closed 1 year ago
it doesn't work either if we make the label optional, that's bad
This would work:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?coords ?date ?film (COALESCE(?film_labell,'') AS ?film_label)
?image ?loc (COALESCE(?loc_labell,'') AS ?loc_label) ?subject
(COALESCE(?subject_labell,'') AS ?subject_label)
WHERE {
?film wdt:P31 wd:Q11424.
?film wdt:P840 ?loc.
?loc wdt:P625 ?coords.
?film wdt:P3383 ?image.
OPTIONAL {
?film wdt:P921 ?subject.
?subject rdfs:label ?subject_labell.
FILTER(lang(?subject_labell) IN ('en'))
}
?film wdt:P577 ?date.
OPTIONAL {
?film rdfs:label ?film_labell.
FILTER(lang(?film_labell) IN ('en'))
}
OPTIONAL {
?loc rdfs:label ?loc_labell.
FILTER(lang(?loc_labell) IN ('en'))
}
}
LIMIT 10
Putting the label in the same optional curly thing, however how would we guess a triple defines a variable whose label we want?
Should we add a heuristic of some sort
if we want to label variable X and it only appears in an optional triple, we put the label there?
But we generally don't handle any grouping at all at the moment.
query$triples shows that "?film blabla ?subject" is optional, subject is not in any other non-optional triple, so subject is the optional element, not film... Would that make sense?
haha same time
Right, so would it make sense to add this, even if we don't handle any other grouping/subqueries kind of things?
Yes, I think so
with #205
library("glitter")
spq_init() %>%
spq_add("?film wdt:P31 wd:Q11424") %>%
spq_add("?film wdt:P840 ?loc") %>%
spq_add("?loc wdt:P625 ?coords") %>%
spq_add("?film wdt:P3383 ?image") %>%
spq_add("?film wdt:P921 ?subject", .required=FALSE) %>%
spq_add("?film wdt:P577 ?date") %>%
spq_label(film,loc,subject) %>%
spq_head(10) %>%
spq_perform()
#> # A tibble: 10 × 8
#> film image loc coords date film_label loc_label
#> <chr> <chr> <chr> <chr> <dttm> <chr> <chr>
#> 1 http://www.wikid… http… http… Point… 2015-01-01 00:00:00 Diary of … France
#> 2 http://www.wikid… http… http… Point… 2015-02-07 00:00:00 Diary of … France
#> 3 http://www.wikid… http… http… Point… 2015-04-01 00:00:00 Diary of … France
#> 4 http://www.wikid… http… http… Point… 2015-04-16 00:00:00 Diary of … France
#> 5 http://www.wikid… http… http… Point… 2015-04-24 00:00:00 Diary of … France
#> 6 http://www.wikid… http… http… Point… 2015-05-13 00:00:00 Diary of … France
#> 7 http://www.wikid… http… http… Point… 2015-05-29 00:00:00 Diary of … France
#> 8 http://www.wikid… http… http… Point… 2015-07-10 00:00:00 Diary of … France
#> 9 http://www.wikid… http… http… Point… 2015-07-15 00:00:00 Diary of … France
#> 10 http://www.wikid… http… http… Point… 2016-01-07 00:00:00 Diary of … France
#> # ℹ 1 more variable: subject_label <chr>
Created on 2023-10-19 with reprex v2.0.2
Hi,
I've encountered an HTTP 500 Internal Server Error with this query:
while the same query without trying to label "subject" works fine. I guess it has something to do with the fact that subject is optional so labelling it should be too?