Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/agrueneberg/Sessel

Document RDFizer for CouchDB
https://github.com/agrueneberg/Sessel

couchapp couchdb nosql rdf semantic-web sparql triple-store

Last synced: 5 days ago
JSON representation

Document RDFizer for CouchDB

Awesome Lists containing this project

README

        

Sessel
======

[![Project Status: Inactive - The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows.](http://www.repostatus.org/badges/0.1.0/inactive.svg)](http://www.repostatus.org/#inactive)

Sessel is a CouchApp for [CouchDB](http://couchdb.apache.org) that generates RDF triples from JSON documents, which then in turn can be exported to various serialization formats, or queried through a SPARQL endpoint.

Installation
------------

Clone this repository and use [CouchApp](http://couchapp.org) to push Sessel to `/`:

git clone https://github.com/agrueneberg/Sessel.git
couchapp push Sessel/ http:///

Alternatively, replicate [an existing deployment of Sessel](https://couchdb.gutpassfilter.de/sessel/) to `/` using `curl`:

curl\
-X POST\
-H "Content-Type:application/json"\
-d "{\"source\":\"https://couchdb.gutpassfilter.de/sessel\",\
\"target\":\"http:///\",\
\"filter\":\"vacuum/rw\"}"\
http://localhost:5984/_replicate

Export
------

The generated triples can be exported to various RDF serialization formats by calling the export interface `http:////_design/sessel/_rewrite/` with one of the following strings added:

* `export.nt` – Export as [N-Triples](http://www.w3.org/TR/rdf-testcases/#ntriples)
* `export.ttl` – Export as [Turtle](http://www.w3.org/TeamSubmission/turtle/)
* `export.rdf` – Export as [RDF/XML](http://www.w3.org/TR/rdf-syntax-grammar/)

A graphical export interface can be accessed at `http:////_design/sessel/export.html`.

### Changing the base URI

The default base URI is `http://host/db_name/`. If you prefer a different URI, add a `base_uri` parameter to the export URL and provide a percent-encoded value, e.g. `http:////_design/sessel/_rewrite/export.ttl?base_uri=http%3A%2F%2Fexample.com%2Frdf%23`.

### Changing the prefix

The default prefix of the base URI is `sessel`. If you prefer a different prefix, add a `prefix` parameter to the export URL and provide a value, e.g. `http:////_design/sessel/_rewrite/export.ttl?base_uri=http%3A%2F%2Fexample.com%2Frdf%23&prefix=example`.

### Data type mapping

The data types of JSON are mapped to the data types of XML as specified in [XML Schema Part 2: Datatypes Second Edition](http://www.w3.org/TR/xmlschema-2/).

* `string` → `xsd:string`
* `array` → `xsd:string`
* `object` → `xsd:string`
* `null` → `xsd:string`
* `number` → `xsd:integer` or `xsd:double`
* `boolean` → `xsd:boolean`

To activate data type mapping, add a `type_literals` parameter to the export URL and provide a string value `true`.

SPARQL Endpoint
---------------

Sessel bundles Antonio Garrote's fantastic [rdfstore-js](https://github.com/antoniogarrote/rdfstore-js), an RDF store with SPARQL support written entirely in JavaScript. A graphical query interface can be accessed at `http:////_design/sessel/sparql.html`.
Unfortunately, modern browsers only let [rdfstore-js](https://github.com/antoniogarrote/rdfstore-js) store 5 MB worth of triples. If your data set is large it is recommended to use a standalone SPARQL processor such as [ARQ](http://jena.sourceforge.net/ARQ/) to import the generated triples by pointing it to the export interface:

SELECT *
FROM //_design/sessel/_rewrite/export.ttl>
WHERE {
?s ?p ?o .
}

Document Conversion
-------------------

Each JSON document is broken down to key-value pairs. Each key-value pair represents a triple, key and value being predicate and object, respectively. The value of the special key-value pair with the key `_id` ensuring the uniqueness of a document serves as the subject of the generated triple.