C++ semantic toolkit + sparqlite RDF database
All the *.h files in the root directory constitute the public API of sparqlxx. They contain structures made for storing parsed SPARQL statements and their results, functions to parse and autocomplete SPARQL (require linking against libsparqlxx-parser), to serialize SPARQL Algebra to SSE, and a Database class for loading and accessing concrete database plugins (like sparqlite)
The biggest single part of the toolkit is the hand-written recursive-descent SPARQL parser. It's located in parser/ and compiled into libsparqlxx-parser.so. All the .h files in parser/ are considered private, the public API is in /parse.h and /autocomplete.h.
Simple implementation of SPARQL RDF database with builtin RDFS/OWL reasoner.
./bin/sparql is a console for interacting with any SPARQL database supported in a sparqlxx plugin (= currently only sparqlite). It supports history and autocompletion of SPARQL queries.
% make
% export LD_LIBRARY_PATH=./lib
% ./bin/sparql
sparqlite> BASE <tag:xtreeme.org,2020:tests>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
INSERT DATA {
<#isIn> a owl:TransitiveProperty.
<#Warsaw> <#isIn> <#Poland>.
<#Poland> <#isIn> <#Europe>.
}
OK
With the given data, it will infer that:
<#Warsaw> <#isIn> <#Europe>.
You can see it with:
sparqlite> BASE <tag:xtreeme.org,2020:tests>
SELECT * WHERE { <#Warsaw> <#isIn> ?what }
?what
<tag:xtreeme.org,2020:tests#Poland>
<tag:xtreeme.org,2020:tests#Europe>
Or you can select everything, including the metadata about the reasoning process:
sparqlite> SELECT * { ?s ?p ?o }
?s ?p ?o
"<tag:xtreeme.org,2020:tests#isIn> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#TransitiveProperty> <urn:x-arq:DefaultGraphNode>"^^<http://xtreeme.org/#statement> <http://xtreeme.org/#source> _:x25
_:x25 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xtreeme.org/#Insertion>
<tag:xtreeme.org,2020:tests#Warsaw> <tag:xtreeme.org,2020:tests#isIn> <tag:xtreeme.org,2020:tests#Europe>
_:x40 <http://xtreeme.org/#inferredFrom> "<tag:xtreeme.org,2020:tests#Warsaw> <tag:xtreeme.org,2020:tests#isIn> <tag:xtreeme.org,2020:tests#Poland> <urn:x-arq:DefaultGraphNode>"^^<http://xtreeme.org/#statement>
"<tag:xtreeme.org,2020:tests#Warsaw> <tag:xtreeme.org,2020:tests#isIn> <tag:xtreeme.org,2020:tests#Poland> <urn:x-arq:DefaultGraphNode>"^^<http://xtreeme.org/#statement> <http://xtreeme.org/#source> _:x31
_:x40 <http://xtreeme.org/#inferredFrom> "<tag:xtreeme.org,2020:tests#isIn> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#TransitiveProperty> <urn:x-arq:DefaultGraphNode>"^^<http://xtreeme.org/#statement>
_:x40 <http://xtreeme.org/#inferredFrom> "<tag:xtreeme.org,2020:tests#Poland> <tag:xtreeme.org,2020:tests#isIn> <tag:xtreeme.org,2020:tests#Europe> <urn:x-arq:DefaultGraphNode>"^^<http://xtreeme.org/#statement>
<tag:xtreeme.org,2020:tests#Warsaw> <tag:xtreeme.org,2020:tests#isIn> <tag:xtreeme.org,2020:tests#Poland>
_:x40 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xtreeme.org/#Inference>
"<tag:xtreeme.org,2020:tests#Warsaw> <tag:xtreeme.org,2020:tests#isIn> <tag:xtreeme.org,2020:tests#Europe> <urn:x-arq:DefaultGraphNode>"^^<http://xtreeme.org/#statement> <http://xtreeme.org/#source> _:x40
<tag:xtreeme.org,2020:tests#Poland> <tag:xtreeme.org,2020:tests#isIn> <tag:xtreeme.org,2020:tests#Europe>
_:x36 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xtreeme.org/#Insertion>
"<tag:xtreeme.org,2020:tests#Poland> <tag:xtreeme.org,2020:tests#isIn> <tag:xtreeme.org,2020:tests#Europe> <urn:x-arq:DefaultGraphNode>"^^<http://xtreeme.org/#statement> <http://xtreeme.org/#source> _:x36
<tag:xtreeme.org,2020:tests#isIn> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#TransitiveProperty>
_:x31 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xtreeme.org/#Insertion>
Copyright (C) 2010 - 2015 Janusz Lewandowski
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.
The project is a rewrite of Xtreeme semantic database. sparqlxx API and parser are completely new, but sparqlite reuses some (strongly refactored) Xtreeme's code.