Skip to content

spq_set should work with URIs (probably) #209

Description

@lvaudor

When working on "combined queries" I often need to replace URIs with their abbreviated versions for use in spq_set().
For instance, I run a first query that returns a list of countries, such as:

country_id="http://www.wikidata.org/wiki/Q142"

Then I want to run a query to get the coordinates of each country, and to do that I define a function:

get_country_coords=function(country_id){
  country_id=stringr::str_replace(country_id, "http://www.wikidata.org/entity/", "wd:")
  result=spq_init() %>%
    spq_set(country=country_id) %>% 
    spq_add("?country wdt:P625 ?coords_country") %>%
    spq_select(-country) %>% 
    spq_perform() 
  result
}

Would that be possible to modify spq_set() so that it works with both "wd:Q142" and full URI ""http://www.wikidata.org/entity/Q142"" (and make that use of stringr::str_replace useless)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions