ropensci / redland-bindings

Redland librdf language bindings
http://librdf.org/bindings/
Other
17 stars 3 forks source link

parse rdf in other formats than rdfxml? #53

Closed cboettig closed 7 years ago

cboettig commented 7 years ago

Is it possible to parse other serialization formats? I see the arguments for initializing a new parser include options to specify the "parser factory" name and mimeType, but can't find a list of supported formats in the package docs or at http://librdf.org/docs/api/redland-parser.html . Probably just missing something obvious. Anyway, I tried:

world <- new("World")
storage <- new("Storage", world, "hashes", name="", options="hash-type='memory'")
model <- new("Model", world, storage, options="")

parser <- new("Parser", world, name = "nquads", mimeType="application/nquads")
filePath <- "ropensci.nquads"
parseFileIntoModel(parser, world, filePath, model)

but no go. More generally, if other serializations are supported, I assume that it would be possible to use redland to convert between them? Or is there an easier / alternate way to do that in R? Thanks!

(Context: the jsonld R wrapper has jsonld_to_rdf which defaults to nquads and I can't figure out how to get it to do other formats either, though I try specifying options=list(format="application/rdf+xml"...).

cboettig commented 7 years ago

Looks like the trick is simply to make sure the name and mimeType match the names and q 1.0 mimeTypes listed here: http://librdf.org/raptor/api/raptor-formats-types-by-parser.html. e.g. for nquads:

test <- new("Parser", world, name="nquads", mimeType="text/x-nquads")