Skip to content

Instantly share code, notes, and snippets.

@martintrojer
Created August 16, 2012 18:36
Show Gist options
  • Save martintrojer/3372484 to your computer and use it in GitHub Desktop.
Save martintrojer/3372484 to your computer and use it in GitHub Desktop.
RDF graph core.logic
;; http://www.infoq.com/presentations/core-logic
(ns rdf
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]))
(def g
[[:a1 :rdf/type :sdx/FederationService]
[:a1 :rdf/type :sdx/name "movies"]
[:a1 :rdf/exposedServices :_syscoll1]
[:_syscoll1 :sdx/service :a2]
[:a2 :rdf/type :sdx/FederationService]
[:a2 :rdf/name "imdb"]
[:a2 :sdx/identifier "<http://base/movies"]
[:a2 :sdx/queryTimeout 5]
[:a2 :rdf/exposedServices :_syscoll2]
[:_syscoll2 :rdf/type :sdx/ServiceCollection]
[:_syscoll2 :sdx/service :a3]
[:_syscoll2 :sdx/service :a4]
[:a3 :rdf/type :sd/Service]
[:a3 :sd/endpoint "http://localhost:9090/spyder/instance2"]
[:a4 :rdf/type :sd/Service]
[:a4 :sd/endpoint "http://localhost:9090/spyder/instance1"]
[:a4 :sd/supportedLanguage :sd/SPARQL11Query]
[:a4 :sd/resultFormat "<http://www.w3.org/ns/formats/Turtle>"]
[:a4 :sd/defualtDatasetDescription :a5]
])
(defn endpointo [g q]
(fresh [a b c d e f]
(membero [a :rdf/type :sdx/FederationService] g)
(membero [a :rdf/exposedServices b] g)
(membero [b :sdx/service c] g)
(membero [c :rdf/type :sdx/FederationService] g)
(membero [c :rdf/exposedServices d] g)
(membero [d :sdx/service e] g)
(membero [e :rdf/type :sd/Service] g)
(membero [e :sd/endpoint q] g)))
(run* [q]
(endpointo g q))
(run 1 [g]
(endpointo g "http://localhost:1234/ole"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment