Search code examples
ontologylinked-datalinked-data-platform

How to use owl:sameAs inferences within Fuseki's Sparql and return every matching instance's properties?


I have the following RDF data in my Fuseki triplestore.

@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> .

I query like this:

SELECT ?predicate ?object
WHERE {
  <http://localhost:3030/eb/School/1> ?predicate ?object
}

with the following result:

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"

I would like to know what should I do to make the query return the wgs84:lat / wgs84:long values from the owl:sameAs instance? Is it possible using a SPARQL query?


Solution

  • What it is needed here is to edit the configuration files (inside the folder /run/configuration/datasetname.ttl), add and restart the Fuseki server.

    :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]" .       
    

    Some links on how to do that:

    Then it behaves just like intended in the question.

    Just to remember, if one wants to link to a third party's vocabulary, one must download the file and load it into Fuseki, to make the infereces work.