egonw / rrdf

R package for handling RDF data.
Other
29 stars 11 forks source link

Support for Sparql Construct #6

Closed ryankohl closed 13 years ago

ryankohl commented 13 years ago

It would be nice if there was support for Sparql Construct statements in the library, so that graphs could be extracted, fiddled with, and merged together.

egonw commented 13 years ago

It would indeed... I have been wanting this for another project I work on (Bioclipse) too... I have to experiment a bit with that, but not sure when I get around to it... a patch is most welcome (by anyone) to start playing with this idea!

ryankohl commented 13 years ago

I think I've got the two snippets that need to be added:

RJenaHelper.java public static Model construct(Model model, String queryString) throws Exception { Model result= null; Query query= QueryFactory.create(queryString); PrefixMapping prefixMap= query.getPrefixMapping(); QueryExecution qexec= QueryExecutionFactory.create(query, model); try { result= qexec.execConstruct(); } finally { qexec.close(); } return result; }

load.rdf.R : construct.rdf <- function(model, sparql) { newModel <- .jcall( "com/github/egonw/rrdf/RJenaHelper", "Lcom/hp/hpl/jena/rdf/model/Model", "construct", model, sparql ) exception <- .jgetEx(clear = TRUE) if (!is.null(exception)) { stop(exception) } return(newModel) }

Not sure how I go about re-building the project..would a jar that I build point to com/github/ryankohl/rrdf/RJenaHelper in load.rdf.R instead of com/github/egonw/rrdf/RJenaHelper?

egonw commented 13 years ago

The README.md should give the full howto compile from source:

https://github.com/egonw/rrdf/blob/master/README.md

Can you give that a try?

If you have not got the git repository checked out, prepend the compile commands with:

git clone git://github.com/egonw/rrdf.git cd rrdf

Egon

egonw commented 13 years ago

I'll try to incorporate this now...

egonw commented 13 years ago

Added:

https://github.com/egonw/rrdf/commit/157891019a87886677ec9f30939bdd0e688b17da

ryankohl commented 13 years ago

Terrific! Thanks for doing the merge - I've been swamped lately.