Generate SPARQL request as S-expression on Common Lisp. Most process are homaged to madnificent/cl-fuseki
- Select
- basic
- limit
- filter
- Insert
- Graph
- Remove dependency of cl-fuseki
- To comply with the W3C statement
- Download this package from github
~ $ cd /path/to/quicklisp/local-projects/
~ $ git clone https://github.com/dbym4820/cl-ignition.git
- Install via quicklisp
CL-USER> (ql:quickload :cl-ignition)
To load "cl-ignition":
Load 1 ASDF system:
cl-ignition
; Loading "cl-ignition"
..
(:CL-IGNITION)
e.g.: get 5 data which has the URI "http://ja.dbpedia.org/resource/冴えない彼女の育てかた" as subject parameter from DBpedia Japan
usage of with-prefix and convert-query macro
CL-USER> (defparameter *sample-query*
(cl-ignition:with-prefix (val)
((dbpedia-jp "http://ja.dbpedia.org/resource/"))
((:select (nil ?p ?o)
:distinct t
:subject (dbpedia-jp "冴えない彼女の育てかた")
:limit 5))
(cl-ignition:convert-query val)))
*SAMPLE-QUERY*
CL-USER> *SAMPLE-QUERY*
"select distinct ?P ?O where { <http://ja.dbpedia.org/resource/冴えない彼女の育てかた> ?P ?O limit 5 . }"
CL-USER> (defparameter *dbpedia-server*
(make-instance 'cl-ignition.fuseki:virtuoso-repository
:name "DBpedia Japanese"
:server (make-instance 'cl-ignition.fuseki:virtuoso-server
:base-url "http://ja.dbpedia.org/sparql")))
*DBPEDIA-SERVER*
CL-USER> *dbpedia-server*
#<CL-IGNITION.FUSEKI:VIRTUOSO-REPOSITORY #x3020022966DD>
CL-USER> (cl-ignition.fuseki:query *dbpedia-server* *sample-query*)
;; =>
((:OBJ ("P" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
("O" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/2002/07/owl#Thing")))
(:OBJ ("P" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
("O" :OBJ ("type" . "uri")
("value" . "http://dbpedia.org/ontology/Anime")))
(:OBJ ("P" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
("O" :OBJ ("type" . "uri")
("value" . "http://dbpedia.org/ontology/Cartoon")))
(:OBJ ("P" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
("O" :OBJ ("type" . "uri")
("value" . "http://dbpedia.org/ontology/Work")))
(:OBJ ("P" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
("O" :OBJ ("type" . "uri")
("value" . "http://schema.org/CreativeWork"))))
CL-USER> (cl-ignition:with-prefix (val)
((dbpedia-jp "http://ja.dbpedia.org/resource/"))
((:select (nil ?p ?o)
:distinct t
:subject (dbpedia-jp "冴えない彼女の育てかた")
:limit 5))
(cl-ignition:request-dbpedia (cl-ignition:convert-query val)))
;; =>
((:OBJ ("P" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
("O" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/2002/07/owl#Thing")))
(:OBJ ("P" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
("O" :OBJ ("type" . "uri")
("value" . "http://dbpedia.org/ontology/Anime")))
(:OBJ ("P" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
("O" :OBJ ("type" . "uri")
("value" . "http://dbpedia.org/ontology/Cartoon")))
(:OBJ ("P" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
("O" :OBJ ("type" . "uri")
("value" . "http://dbpedia.org/ontology/Work")))
(:OBJ ("P" :OBJ ("type" . "uri")
("value" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
("O" :OBJ ("type" . "uri")
("value" . "http://schema.org/CreativeWork"))))
- Tomoki Aburatnai (aburatanitomoki@gmail.com)
Copyright (c) 2018 Tomoki Aburatnai (aburatanitomoki@gmail.com)
Licensed under the MIT License.