
Get labels in a specified language (apply only to Wikidata)
Source:R/spq_language.R
spq_language.RdGet labels in a specified language (apply only to Wikidata)
Arguments
- .query
the query
- language
the language in which the labels will be provided (defaults to "en" for English). See complete list of Wikimedia language codes. You can also set language to "auto" and then the Wikidata SPARQL engine will try and detect your language automatically. Specifying several languages will return labels with languages following the priority specified (e.g. with language="fr,en", the label will be returned preferentially in French, or, if there is not French label for the item, in English).
Examples
spq_init() %>%
spq_add("?film wdt:P31 wd:Q11424") %>%
spq_label(film, .languages = c("fr$", "en$")) %>%
spq_head(10)
#> 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 ?film (COALESCE(?film_labell,'') AS ?film_label) (lang(?film_labell) AS
#> ?film_label_lang)
#> WHERE {
#>
#> ?film wdt:P31 wd:Q11424.
#> OPTIONAL {
#> ?film rdfs:label ?film_labell.
#> FILTER(lang(?film_labell) IN ('fr') || lang(?film_labell) IN ('en'))
#> }
#>
#>
#> }
#>
#> LIMIT 10