对于学习 SPARQL,完全控制查询文本和数据(RDF 三元组)可能会很有用。虽然有许多公共 SPARQL 端点可用,但由于显而易见的原因,它们的数据通常是只读的。要主动将 SPARQL 查询应用于自己的数据,本地三元组存储可能会很有用,例如用于重现来自 https://www.w3.org/TR/rdf-sparql-query/.
的示例但是,设置这样的基础设施及其所有依赖项可能会很复杂。
→ 在普通 PC 上使用 SPARQL 端点设置本地三重存储的 最简单¹ 方法是什么?
(1:“最简单”的含义取决于系统配置和先验知识,可以通过不同的答案反映出来。)
基于java的解决方案是:
https://jena.apache.org/download/index.cgi
下载 Apache Jena Fuseki zip。 解压缩 zip,运行
fuseki-server
。http://localhost:3030/
如果已经有了 Python 环境,那么 rdflib-endpoint 提供了一种简单的解决方案,只需两个命令
pip install rdflib-endpoint
(运行一次)rdflib-endpoint serve <path_to_your_triple-file(s)>
也许 https://triplydb.com 对您来说很有趣。您可以像这样创建数据集。 https://triplydb.com/Triply/linkedmdb/sparql/linkedmdb
通过 docker 使用 Eclipse RDF4J:
docker pull eclipse/rdf4j-workbench:latest
docker run -p 8080:8080 eclipse/rdf4j-workbench:latest
然后访问http://localhost:8080/rdf4j-workbench
oxigraph(https://github.com/oxigraph/oxigraph)! (您也可能会发现相关项目很有趣https://crates.io/crates/reasonable)
顺便说一句。看起来 rdflib-endpoint(前面提到的)可以通过
rdflib-endpoint --store Oxigraph ...
配置为使用 oxigraph!
cargo isntall oxigraph_server
或
通过 Docker:
复制自https://crates.io/crates/oxigraph_server#using-a-docker-image:
docker run --rm ghcr.io/oxigraph/oxigraph --help
在主机的
7878
端口暴露服务器,并将数据保存在本地./data
文件夹
docker run --rm -v $PWD/data:/data -p 7878:7878 ghcr.io/oxigraph/oxigraph --location /data serve --bind 0.0.0.0:7878
然后您可以从您的计算机上的端口
7878
访问它:
# Open the GUI in a browser
firefox http://localhost:7878
# Post some data
curl http://localhost:7878/store?default -H 'Content-Type: text/turtle' -T ./data.ttl
# Make a query
curl -X POST -H 'Accept: application/sparql-results+json' -H 'Content-Type: application/sparql-query' --data 'SELECT * WHERE { ?s ?p ?o } LIMIT 10' http://localhost:7878/query
# Make an UPDATE
curl -X POST -H 'Content-Type: application/sparql-update' --data 'DELETE WHERE { <http://example.com/s> ?p ?o }' http://localhost:7878/update