如何在Fuseki的Sparql中使用owl:sameAs推论,并返回每个匹配实例的属性?

问题描述 投票:0回答:1

我在Fuseki Triplestore中具有以下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"

我想知道如何使查询从owl:sameAs实例返回wgs84:lat / wgs84:long值?是否可以使用SPARQL查询?

ontology linked-data linked-data-platform
1个回答
0
投票

这里需要编辑配置文件(在文件夹/ 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]" .       

一些有关操作方法的链接:

然后,它的行为就和问题中的预期一样。

请记住,如果要链接到第三方的词汇表,则必须下载该文件并将其加载到Fuseki中,以使推断生效。

© www.soinside.com 2019 - 2024. All rights reserved.