I've been having a go at a Clojure binding for Commons RDF here:

https://github.com/stain/commons-rdf-clj

I was not quite sure which direction to take it, as I was not sure
what an RDF library should look like in Clojure, and still be
interoperable with the Commons RDF types.


https://github.com/stain/commons-rdf-clj/blob/master/src/commons_rdf_clj/core.clj
is a straight forward binding that would just make accessor functions,
and still pass around the Commons RDF objects.  So you couldn't do any
other Clojure-things on them directly, and there would be lots of such
functions (that code is incomplete).


I then made 
https://github.com/stain/commons-rdf-clj/blob/master/src/commons_rdf_clj/graph.clj
as a rough draft of what Commons RDF done natively in Clojure would
feel like - e.g. (:subject triple) and just keeping triples in a list,
where you can use (filter) etc.


https://github.com/stain/commons-rdf-clj/blob/master/src/commons_rdf_clj/types.clj
is an attempt to make a couple of protocols for RDF stuff, which can
be used with Commons RDF and also native Clojure types like lists and
dicts.  -- this has the disadvantage that you can't so easily move
between the implementations, however in the RDFTermFactory extension
you see it supports both Commons RDF parameters and coerces the
regular Clojure types following the protocol.

A bigger job here would be to extend the PGraph protocol beyond
(add-triple), and to provide implementation the other way, e.g. let
common Clojure structure directly appear as an Commons RDF
implementations.  Which way to go here depends a bit on how this would
be used..  I didn't do this as I thought it would be better to have
something like:

Jena -> Commons RDF -> commons-rdf-clj

so that commons-rdf-clj exposes Jena objects (via Commons RDF), but as
something that is usable in a more native Clojure way, and pluggable
to other backends.



On 27 August 2015 at 17:56, Joël Kuiper <m...@joelkuiper.eu> wrote:
> Hey Andy,
>
> So I’m working on a SPARQL library for Clojure (YeSPARQL, 
> https://github.com/joelkuiper/yesparql) and I’m at the point where I want to 
> convert Jena native Node, RDFNode, Literal, Triple… objects to formats more 
> convenient to work with in Clojure itself (maps, records).
>
> Now it would be nice if I can use some common format, abstracting away from 
> that implementation detail and potentially opening up the door for inter-op 
> with other RDF libraries.
>
> Now it could very well be that this is a case of “we’ll solve it with one 
> more layer of abstraction” ad infinitum, but at first glance it seems like it 
> might be a nice fit for writing inter-op with other non-Java JVM libraries.
>
> Joël
>
>
>> On 26 Aug 2015, at 17:18, Andy Seaborne <a...@apache.org> wrote:
>>
>> My first pass at this is:
>> https://github.com/afs/commonsrdf-jena
>>
>> All packaging and class names temporary.
>>
>> What might be more useful is:
>>
>> https://github.com/afs/commonsrdf-jena/blob/master/src/main/java/org/apache/jena/commons/Example1.java
>>
>> which shows Jena parsing to any commons-rdf Graph.
>> The ToGraph class is factory implementation neutral.
>>
>> Joël - I'm interested in how you would use CommonsRDF. What use cases do you 
>> have in mind?  And where does the data come from or is it created by your 
>> code?
>>
>> https://github.com/afs/commonsrdf-container
>> is a minimal implementation of CommonsRDF - even less than the "simple" one 
>> as a test of the designs.
>>
>>       Andy
>>
>>> On Aug 26, 2015, at 7:45 AM, Joël Kuiper <m...@joelkuiper.eu> wrote:
>>>
>>>> Hey all,
>>>>
>>>> I just got wind of CommonsRDF https://commonsrdf.incubator.apache.org/, 
>>>> and it looks great!
>>>> It’d be exciting to use this for some of the libraries I’m working on.
>>>> Unfortunately I couldn’t find any reference to it in Jena (except for a 
>>>> note on CommonsRDF that it might come to Jena 3.0)
>>>>
>>>> Can somebody fill me in on the progress of this project?
>>>>
>>>> Thanks in advance!
>>>>
>>>>
>>>> ---
>>>> Joël Kuiper
>>>> www.joelkuiper.eu
>>>>
>>>
>>
>



-- 
Stian Soiland-Reyes
Apache Taverna (incubating), Apache Commons RDF (incubating)
http://orcid.org/0000-0001-9842-9718

Reply via email to