如何在 Fuseki 的 Sparql 和 return 每个匹配实例的属性中使用 owl:sameAs 推理?
How to use owl:sameAs inferences within Fuseki's Sparql and return every matching instance's properties?
我的 Fuseki 三重存储中有以下 RDF 数据。
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix schema: <http://schema.org/> .
@prefix ex: <http://localhost:3030/eb/> .
@prefix wgs84: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
ex:School rdf:type owl:Class .
<http://localhost:3030/eb/School/1> rdf:type ex:School ;
schema:name "Escola 1" .
ex:NewSchool rdf:type owl:Class .
<http://localhost:3030/eb/NewSchool/1> rdf:type ex:NewSchool ;
wgs84:lat "23.085980" ;
wgs84:long "-5.692" .
<http://localhost:3030/eb/School/1> owl:sameAs <http://localhost:3030/eb/NewSchool/1> .
我这样查询:
SELECT ?predicate ?object
WHERE {
<http://localhost:3030/eb/School/1> ?predicate ?object
}
结果如下:
predicate object
<http://www.w3.org/2002/07/owl#sameAs> <http://localhost:3030/eb/NewSchool/1>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://localhost:3030/eb/Escola>
<http://schema.org/name> "Escola 1"
我想知道我应该怎么做才能使查询 return wgs84:lat / wgs84:long 来自 owl:sameAs 实例的值?是否可以使用 SPARQL 查询?
这里需要编辑配置文件(在文件夹/run/configuration/datasetname.ttl),添加并重启Fuseki服务器。
:service1 a fuseki:Service ;
fuseki:dataset :inferred_dataset ;
:inferred_dataset a ja:RDFDataset ;
ja:defaultGraph :inference_model .
:inference_model a ja:InfModel ;
ja:baseModel :tdb_graph ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
] .
:tdb_graph a tdb:GraphTDB ;
tdb:dataset :tdb_dataset_readwrite .
:tdb_dataset_readwrite
a tdb:DatasetTDB ;
tdb:location "[MyDatasetLocationOnDisk]" .
一些 link 如何做到这一点:
https://christinemdraper.wordpress.com/2017/04/09/getting-started-with-rdf-sparql-jena-fuseki/
https://gist.github.com/ruebot/fb7b1da82042860138d2d609756e07dc
configure fuseki with TDB2 and OWL Reasoner
那么它的行为就像问题中预期的那样。
请记住,如果想 link 第三方词汇表,必须下载文件并将其加载到 Fuseki 中,才能进行推理。
我的 Fuseki 三重存储中有以下 RDF 数据。
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix schema: <http://schema.org/> .
@prefix ex: <http://localhost:3030/eb/> .
@prefix wgs84: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
ex:School rdf:type owl:Class .
<http://localhost:3030/eb/School/1> rdf:type ex:School ;
schema:name "Escola 1" .
ex:NewSchool rdf:type owl:Class .
<http://localhost:3030/eb/NewSchool/1> rdf:type ex:NewSchool ;
wgs84:lat "23.085980" ;
wgs84:long "-5.692" .
<http://localhost:3030/eb/School/1> owl:sameAs <http://localhost:3030/eb/NewSchool/1> .
我这样查询:
SELECT ?predicate ?object
WHERE {
<http://localhost:3030/eb/School/1> ?predicate ?object
}
结果如下:
predicate object
<http://www.w3.org/2002/07/owl#sameAs> <http://localhost:3030/eb/NewSchool/1>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://localhost:3030/eb/Escola>
<http://schema.org/name> "Escola 1"
我想知道我应该怎么做才能使查询 return wgs84:lat / wgs84:long 来自 owl:sameAs 实例的值?是否可以使用 SPARQL 查询?
这里需要编辑配置文件(在文件夹/run/configuration/datasetname.ttl),添加并重启Fuseki服务器。
:service1 a fuseki:Service ;
fuseki:dataset :inferred_dataset ;
:inferred_dataset a ja:RDFDataset ;
ja:defaultGraph :inference_model .
:inference_model a ja:InfModel ;
ja:baseModel :tdb_graph ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
] .
:tdb_graph a tdb:GraphTDB ;
tdb:dataset :tdb_dataset_readwrite .
:tdb_dataset_readwrite
a tdb:DatasetTDB ;
tdb:location "[MyDatasetLocationOnDisk]" .
一些 link 如何做到这一点:
https://christinemdraper.wordpress.com/2017/04/09/getting-started-with-rdf-sparql-jena-fuseki/
https://gist.github.com/ruebot/fb7b1da82042860138d2d609756e07dc
configure fuseki with TDB2 and OWL Reasoner
那么它的行为就像问题中预期的那样。
请记住,如果想 link 第三方词汇表,必须下载文件并将其加载到 Fuseki 中,才能进行推理。