This is a small library to make it easier to work with RDF and SPARQL in Clojure 1.4. Uploaded to Clojars at http://clojars.org/seabass
Add the following line to your dependencies:
[seabass "2.1"]
Takes n-many arguments and returns an RDF model. These arguments can be
This executes a SELECT query against an RDF model, returning a map with the following keys:
The arguments are:
This executes an ASK query against an RDF model, returning a Boolean value. The arguments are:
This executes a CONSTRUCT query against an RDF model, returning a new RDF model. The arguments are:
Writes the contents of a model to the file specified by the target string.
The resulting file is encoded in n-triples. Only RDF facts are written
(i.e. not rules). Returns the path name of the written file (ie the
provided 'target' parameter).
These functions return Jena triples, which can be pushed into a model.
These functions return Jena triples, which can be pushed into a model.
Asserts a collection of triples into the target, which can either be a Jena model or a remote endpoint uri string.
(def c "construct {?x <http://seabass.foo/bar> ?y}
{ ?y <http://example.org/baz> ?x }")
(def m (build ["data/my-ontology.rdf" "TTL"]
"http://way.out.there/my-data.nt"
(pull c "http://my-endpoint/sparql")))
(def endpoint "http://localhost:8080/openrdf-sesame/repositories/test/statements")
(def r1 (resource-fact "http://foo/luke" "http://foo/sibling" "http://foo/leia"))
(def r2 (resource-fact "_:v" "http://foo/father" "http://foo/luke"))
(def l1 (literal-fact "_:v" "http://foo/wears" "http://foo/cape"))
(push endpoint [r1 r2 l1])
(ask "ask {}" "http://my-endpoint/sparql")
(def q "select ?x ?y ?z
{?x <http://ex.org/foo> ?y .
?z <http://ex.org/bar ?y . }")
(def m (build "data/my-ont.ttl" "data/your-ont.owl"))
(bounce q m)
All built-ins supported in Jena 2.9.2 (the current release as of April, 2011) can be used. The following built-ins have been added for Jena Rules (i.e. in .rules files, and not in Sparql queries):
Copyright (C) 2012 Ryan Kohl
Distributed under the Eclipse Public License, the same as Clojure.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close