Open cboettig opened 2 years ago
@cboettig do you have an example of a to-be-saved-locally triplestore & a related query? Maybe in one of your packages?
@maelle sure, of course anything can be a triplestore, so there's a few examples in https://cran.r-project.org/web/packages/rdflib/vignettes/rdf_intro.html
more meaningful examples though are probably easiest to generate by taking anything that provides json-ld and using that as RDF triples. There's some toy examples in that vignette, or just grab any schema.org markup (codemeta files, or JSON-LD from DataCite or EarthCube, e.g. https://github.com/ESIPFed/science-on-schema.org/blob/master/examples/dataset/full.jsonld)
@cboettig
doc <- system.file("extdata", "dc.rdf", package="redland")
library("glitter")
(sparql <- spq_init() %>%
spq_prefix(prefixes = c(dc = "http://purl.org/dc/elements/1.1/")) %>%
spq_mutate(c = dc::creator(a)) %>%
spq_select(a, c) %>%
spq_assemble())
#> [1] "PREFIX dc: <http://purl.org/dc/elements/1.1/>\nSELECT ?a ?c\nWHERE {\n\n?a dc:creator ?c.\n\n}\n\n"
rdf <- rdflib::rdf_parse(doc)
rdflib::rdf_query(rdf, sparql)
#> Rows: 1 Columns: 2
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (2): a, c
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 1 × 2
#> a c
#> <chr> <chr>
#> 1 http://www.dajobe.org/ Dave Beckett
Created on 2023-08-30 with reprex v2.0.2
Really nice package here, and love the clever name!
Just curious if you would have plans to allow
glitter
to send sparql queries to other backends? Though I haven't had a chance to explore more deeply, looks like the package examples use the {SPARQL} R package to query a handful of existing public triplestores over HTTP. I was just thinking R users might like to use this to query their own data as well, e.g. via triplestores created or connected via rdflib / redland or virtuoso wrappers.