Closed lvaudor closed 1 year ago
Hey!
I have been trying to write a function that would make it possible to find the label of a thing (it's something I need for the development of sequins but I guess the issue's place is actually here). For instance, calling
label("wd:Q152088", "en")
would return "french fries".
Well, the following function does the trick:
label=function(string, endpoint="Wikidata", language="en", labelling_prop="rdfs:label"){ if(stringr::str_detect(string,"^\\?")){ return(string) } result=spq_init() %>% spq_add(glue::glue("{string} {labelling_prop} ?string_label")) %>% spq_mutate(languages=lang(string_label)) %>% spq_perform(endpoint=endpoint) %>% dplyr::filter(languages==language) %>% .$string_label return(result) }
The thing is, I would also like to label properties with it. For instance
label("wdt:P31", "en")
would return "instance of". Unfortunately, it does not. It only works for "wd:P31" (without the "t"). In the same spirit
label("rdfs:name", "en")
returns nothing (which is not surprising, but let's dream big).
Can you think of a way to label "usual" or Wikidata "wdt" properties as they appear in the queries themselves?
is this a duplicate of #201?
Ah, yes ! (tiens, j'ai de la suite dans les idées ;-))
Duplicate of #201
Hey!
I have been trying to write a function that would make it possible to find the label of a thing (it's something I need for the development of sequins but I guess the issue's place is actually here). For instance, calling
would return "french fries".
Well, the following function does the trick:
The thing is, I would also like to label properties with it. For instance
would return "instance of". Unfortunately, it does not. It only works for "wd:P31" (without the "t"). In the same spirit
returns nothing (which is not surprising, but let's dream big).
Can you think of a way to label "usual" or Wikidata "wdt" properties as they appear in the queries themselves?