You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Scott Henninger <Sc...@ecstech.com> on 2024/08/26 21:57:39 UTC

Named graphs and inference

Is it possible to configure Fuseki to run inferences across named graphs and have the triples, including the inferred triples, appear in the default graph?

In my attempt to do this, included below (along with the triples I'm testing with), I have a configuration that will run the inferences as desired and they are materialized in the default graph.  However those inferences persist after performing a DROP GRAPH on the named graphs.  In fact, the inferences persist even after restarting Fuseki.  I have to manually do a DELETE on the default graph to get them to go away.

So is it possible to run inference, see the inferred triples on the default graph, and be able to manage the triples with the named graphs?

Thanks in advance
-- Scott

@prefix :       <http://base/#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix ja:     <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:   <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb:   <http://jena.apache.org/2016/tdb#> .

# --- the basic fuseki service (endpoints) with pointer to dataset --
:service_tdb_all  a               fuseki:Service ;
    fuseki:dataset                :dataset ;
    fuseki:name                   "test-inf" ;
    fuseki:serviceQuery           "query" , "" , "sparql" ;
    fuseki:serviceReadGraphStore  "get" ;
    fuseki:serviceReadQuads       "" ;
    fuseki:serviceReadWriteGraphStore "data" ;
    fuseki:serviceReadWriteQuads  "" ;
    fuseki:serviceUpdate          "" , "update" ;
    fuseki:serviceUpload          "upload" .

# --- define the default graph (with inference)  ---
:dataset a ja:RDFDataset ;
    ja:defaultGraph :model_inf ;
.

# --- add inference to the graph ---
:model_inf a ja:InfModel ;
     ja:baseModel :graph ;
     ja:reasoner [
         ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
     ] ;
.

:graph rdf:type tdb:GraphTDB ;
  tdb:dataset :tdb_dataset_readwrite ;
  tdb:unionDefaultGraph true ;
.

:tdb_dataset_readwrite
    a       tdb:DatasetTDB2 ;
    tdb:location  "../Fuseki/run/databases/dev" ;
.

######################################################################
# Loaded in http://example.org/test-ont
@prefix ex: <http://example.org/test#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

ex:Class1 a owl:Class .

ex:SubClass1 a owl:Class ;
    rdfs:subClassOf ex:Class1 .

######################################################################
# Loaded in http://example.org/test-data (inference in default graph is as expected, that ex:Instance1 is a member of ex:Class1)
@prefix ex: <http://example.org/test#> .

ex:Instance1 a ex:SubClass1



Re: Named graphs and inference

Posted by Andy Seaborne <an...@apache.org>.

On 26/08/2024 22:57, Scott Henninger wrote:
> Is it possible to configure Fuseki to run inferences across named graphs and have the triples, including the inferred triples, appear in the default graph?

I don't think it's possible if you want to more complicated in the 
inference than your experiment.

There is something specific to RDFS (subLClassOf, subPropertyOf, domain 
and range, not the axiomatic inferences of full RDFS).

https://jena.apache.org/documentation/rdfs/

It's backward chaining at runtime. The separate schema is processed and 
subX expanded but the data isn't updated.

> In my attempt to do this, included below (along with the triples I'm testing with), I have a configuration that will run the inferences as desired and they are materialized in the default graph.  However those inferences persist after performing a DROP GRAPH on the named graphs.

In the configuration, there aren't any named graphs. See below.

>  In fact, the inferences persist even after restarting Fuseki.  I have to manually do a DELETE on the default graph to get them to go away.
> 
> So is it possible to run inference, see the inferred triples on the default graph, and be able to manage the triples with the named graphs?
> 
> Thanks in advance
> -- Scott
> 
> @prefix :       <http://base/#> .
> @prefix fuseki: <http://jena.apache.org/fuseki#> .
> @prefix ja:     <http://jena.hpl.hp.com/2005/11/Assembler#> .
> @prefix rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix rdfs:   <http://www.w3.org/2000/01/rdf-schema#> .
> @prefix tdb:   <http://jena.apache.org/2016/tdb#> .
> 
> # --- the basic fuseki service (endpoints) with pointer to dataset --
> :service_tdb_all  a               fuseki:Service ;
>      fuseki:dataset                :dataset ;
>      fuseki:name                   "test-inf" ;
>      fuseki:serviceQuery           "query" , "" , "sparql" ;
>      fuseki:serviceReadGraphStore  "get" ;
>      fuseki:serviceReadQuads       "" ;
>      fuseki:serviceReadWriteGraphStore "data" ;
>      fuseki:serviceReadWriteQuads  "" ;
>      fuseki:serviceUpdate          "" , "update" ;
>      fuseki:serviceUpload          "upload" .
> 
> # --- define the default graph (with inference)  ---
> :dataset a ja:RDFDataset ;
>      ja:defaultGraph :model_inf ;

Default graph.

> .
> 
> # --- add inference to the graph ---
> :model_inf a ja:InfModel ;
>       ja:baseModel :graph ;
>       ja:reasoner [
>           ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
>       ] ;
> .
> 
> :graph rdf:type tdb:GraphTDB ;

Default graph.

>    tdb:dataset :tdb_dataset_readwrite ;
>    tdb:unionDefaultGraph true ;

I think that is going to be ignored - it has meaning on the dataset, not 
a graph.


> .
> 
> :tdb_dataset_readwrite
>      a       tdb:DatasetTDB2 ;
>      tdb:location  "../Fuseki/run/databases/dev" ;
> .
> 
> ######################################################################
> # Loaded in http://example.org/test-ont
> @prefix ex: <http://example.org/test#> .
> @prefix owl: <http://www.w3.org/2002/07/owl#> .
> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
> 
> ex:Class1 a owl:Class .
> 
> ex:SubClass1 a owl:Class ;
>      rdfs:subClassOf ex:Class1 .
> 
> ######################################################################
> # Loaded in http://example.org/test-data (inference in default graph is as expected, that ex:Instance1 is a member of ex:Class1)
> @prefix ex: <http://example.org/test#> .
> 
> ex:Instance1 a ex:SubClass1
> 
> 
>