lvaudor / glitter

an R package which writes SPARQL queries
https://lvaudor.github.io/glitter
44 stars 5 forks source link

OPTIONAL support #139

Open maelle opened 1 year ago

maelle commented 1 year ago
maelle commented 1 year ago

in #142 we add filters for optional patterns.

maelle commented 1 year ago

related to #202

maelle commented 1 year ago

In dm there's something called zooming https://dm.cynkra.com/reference/dm_zoom_to.html#ref-examples

maelle commented 1 year ago
spq_init() %>%
  spq_add(blabla) %>%
  spq_filter(blabla) %>%
  spq_optional({
    spq_add(blop) %>%
    spq_label(blop) %>%
    spq_filter(blop)
})

is maybe too close to the SPARQL syntax.

lvaudor commented 1 year ago

I think we could consider that for spq_label, spq_filter, spq_mutate the result is optional if the "ancestor variable" is optional.

So 1) we'd complete query$vars with a new column stating whether the variable is optional or not: the variable would be considered optional if involved only in optional triple patterns. 2) all spq_label, spq_filter, spq_mutate calls with an optional variable as the ancestor variable would be optional.

maelle commented 1 year ago

ok, I'll try that (maybe next week if not this week), let's see how far we can go with this.

do you have more examples?

maelle commented 1 year ago

I think we could consider that for spq_label, spq_filter, spq_mutate the result is optional if the "ancestor variable" is optional.

@lvaudor do you have examples for when this would happen for the filtering and mutating?