guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: neon: git for structured data [Was: Functional database]


From: Roel Janssen
Subject: Re: neon: git for structured data [Was: Functional database]
Date: Wed, 21 Feb 2018 17:02:07 +0100
User-agent: mu4e 0.9.18; emacs 25.1.1

Attachment: rdf.scm
Description: Binary data

Dear Amirouche,

I'm not exactly sure if this fits in with your plans, but nevertheless
I'd like to share this code with you.

I recently looked into using triple stores (actually quad stores)
and wrote an interface to Redland librdf for Guile.

I attached the source code of the interface.
With this interface, you can write something like this:

--8<---------------cut here---------------start------------->8---
(use-modules (redland rdf) ; The attached module.
             (system foreign))

(define world (rdf-world-new))
(rdf-world-open world)

(define store (rdf-storage-new
               world
               "hashes"
               "redland"
               "new=true,hash-type='bdb',dir='path/to/triplestore'"))

(define model (rdf-model-new world store %null-pointer))

(define local-uri (rdf-uri-new world "http://localhost:5000/Redland/";))
(define s (rdf-node-new-from-uri-local-name world local-uri "Test"))
(define p (rdf-node-new-from-uri-local-name world local-uri "TestPredicate"))
(define o (rdf-node-new-from-uri-local-name world local-uri "TestObject"))

(define statement (rdf-statement-new-from-nodes world s p o))
(rdf-model-add-statement model statement)
(rdf-statement-free statement)

(rdf-model-size model)
(rdf-storage-size store)

;; Example mime-type: application/rdf+xml
(define serializer (rdf-serializer-new world %null-pointer "text/turtle" 
%null-pointer))
(define serialized (rdf-serializer-serialize-model-to-string serializer 
local-uri model))
(format #t "Serialized: ~s~%" (pointer->string serialized))

(rdf-uri-free local-uri)
(rdf-model-free model)
(rdf-storage-free store)
(rdf-world-free world)
--8<---------------cut here---------------end--------------->8---

Kind regards,
Roel Janssen


Amirouche Boubekki writes:

> I tried chez scheme and I think GNU Guile
> is a better platform for what I am trying
> to achieve, so I am back.
>
> I also know better what I want to achieve.
> I will create a triple store that comply
> with semantic web standard that is
> a RDF triple store. At [0] and [1] you will
> find a primer on what is RDF in the former
> and the concepts in the latter.
>
> [0] https://www.w3.org/TR/rdf11-primer/
> [1] https://www.w3.org/TR/rdf11-concepts/
>
> It will also be branch-able etc... like git.
>
> Also, I also plan to implement sparql.
> If you find sparql difficult I recommend
> the tutorial at data.world [2] in the mean time.
> It's not very difficult and looks like SQL.
> Hence I also plan to implement sparql [3].
>
> [2] https://docs.data.world/tutorials/sparql/
> [3] https://www.w3.org/TR/sparql11-overview/
>
> What I want to do is something similar to data.world,
> that is a gitlab-like platform for data and replace
> the use of git in projects like datahub.io [4].
>
> [4] http://datahub.io/core/registry
>
> Enough talking, what is the status? Well I finished
> porting what I had in chez and can now run the following
> scenario:
>
> - In master branch, I commit two triples
>
> - In other branch, that is orphan branch, I commit
>    two triples among where one of them overlaps with
>    master.
>
> - I can query both branch
>
> - In a merge commit, I fix the conflict between both
>    branch.
>
> - I can query the resulting branch and get the expected
>    result.
>
> The code might be easier to read [5]
>
> [5] https://github.com/amirouche/neon/blob/master/guile/neon.scm
>
> What is missing, in order of difficulty:
>
> - microkanren package
>    https://framagit.org/a-guile-mind/microkanren
>
> - wiredtiger 3 package
>
> - Turtle aka. .ttl format parser https://www.w3.org/TR/turtle/
>
> - sparql queries parser https://www.w3.org/TR/rdf-sparql-query/
>
> - I am not sure of the status of guile-squee yet
>    https://notabug.org/cwebber/guile-squee/
>
> - pluggable backends
>
> If you want to work one of this item, send me an email.
>
> What I plan to work on next:
>
>    There is a semantic difference between neon
>    and RDF triple stores. In a triple store you
>    can have as many times as you want the same
>    attribute given a subject. That is (ref subject)
>    doesn't return a proper alist.
>
> There is two other links that remain to be cited
>
> - https://www.w3.org/TR/rdf11-mt/
>
> - https://www.w3.org/TR/2014/NOTE-rdf11-datasets-20140225/
>
> Happy hacking,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]