Skip to contents

Assemble query parts into a proper SPARQL query

Usage

spq_assemble(.query, strict = TRUE)

Arguments

.query

a list with elements of the query

strict

whether to perform some linting on the query, and error in case a problem is detected.

Value

A query object

Examples

spq_init() %>%
  spq_add("?city wdt:P31 wd:Q515") %>%
  spq_label(city, .languages = "fr$") %>%
  spq_add("?city wdt:P1082 ?pop") %>%
  spq_assemble() %>%
  cat()
#> PREFIX wd: <http://www.wikidata.org/entity/>
#> PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#> SELECT ?city (COALESCE(?city_labell,'') AS ?city_label) ?pop
#> WHERE {
#> 
#> ?city wdt:P31 wd:Q515.
#> OPTIONAL {
#> 	?city rdfs:label ?city_labell.
#> 	FILTER(lang(?city_labell) IN ('fr'))
#> }
#> 
#> ?city wdt:P1082 ?pop.
#> 
#> }
#>