Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of "?s ?v {object}" in functions #170

Open
lvaudor opened this issue Sep 7, 2023 · 2 comments
Open

Use of "?s ?v {object}" in functions #170

lvaudor opened this issue Sep 7, 2023 · 2 comments

Comments

@lvaudor
Copy link
Owner

lvaudor commented Sep 7, 2023

Hey!

I'm working on a vignette in which I want to run a "combined" query. First I go and search laboratory identifiers (lab) and then I try and find all publishing people affiliated to this lab.

For example, lab_EVS="https://data.archives-ouvertes.fr/structure/390864"

This does not work if I remove the call to glue::glue(), I guess because of something to do with environments :

get_docs_lab=function(lab){
  lab=paste0("<",lab,">")
  result=spq_init() %>%      
  spq_add(glue::glue("?createur hal:structure {lab}")) %>% 
  spq_add("?createur hal:person ?personne") %>%        
  spq_add("?personne foaf:name ?auteur") %>% 
  spq_group_by(auteur) %>% 
  spq_summarise() %>% 
  spq_perform("hal")    
  return(result)
}
get_docs_lab(lab_EVS)

I find that (mildly) annoying because the use of this {object} notation in triple patterns is mainly useful when used in combined queries and thus in functions (well, for those who use purrr instead of [for] loops anyway).

Actually the only other use that I can think of the {object} notation (when not used for iterative processes) is keeping the query "nice and concise" i.e. instead of showing long urls in the code, one can assign a name to these urls and use the name in the query.

(Anyway, the necessity to use glue::glue is NOT a big problem but it's still something more to think of when building combined queries so I just thought I should document this somewhere ;-) )

@maelle
Copy link
Collaborator

maelle commented Sep 7, 2023

Ah nice, let me look how {cli} handles this, I know it has glue-like syntax. Or we could use glue under the hood anyway 🤔

@maelle
Copy link
Collaborator

maelle commented Sep 7, 2023

mmh so it's not as easy as I thought.

I wonder whether it's worth the complexity, honestly, compared to letting the users construct their strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants