You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Guy Laden <LA...@il.ibm.com> on 2013/10/09 14:36:36 UTC

transitive reasoning and named graphs

We are running into an issue trying to use reasoning with Fuseki over
owl:TransitiveProperties.

Our example (below) works when the triples are uploaded into the default
graph but when we upload them to a named graph reasoning doesn't seem to
work. (We have tried querying both the named graph and the default graph)

The triples
--------------
<http://localhost/onto#prop1> a
<http://www.w3.org/2002/07/owl#TransitiveProperty> .
<http://localhost:9090/part1> <http://localhost/onto#prop1>
<http://localhost:9090/part2> .
<http://localhost:9090/part2> <http://localhost/onto#prop1>
<http://localhost:9090/part3> .
<http://localhost:9090/part3> <http://localhost/onto#prop1>
<http://localhost:9090/part4> .

The query
-------------
SELECT DISTINCT * where {
{
GRAPH ?g {
 <http://localhost:9090/part1> <http://localhost/onto#prop1> ?part .
}
} UNION {
<http://localhost:9090/part1> <http://localhost/onto#prop1> ?part .
}
}

When we upload to some named graph we get no results (even if
unionDefaultGraph is set to true)

When we upload to the default graph the results we get are:
| part                          |
=================================
| <http://localhost:9090/part2> |
| <http://localhost:9090/part3> |
| <http://localhost:9090/part4> |
---------------------------------

We tried the query like above, with the UNION, as well as with each variant
separately.

We have tried both fuseki 1.0.0 and 0.2.7

Below is the Fuseki config file we are using.

What are we missing?

Thanks, Guy

------------------------

@prefix :        <#> .
@prefix fuseki:  <http://jena.apache.org/fuseki#> .
@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.hpl.hp.com/2008/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .

[] rdf:type fuseki:Server ;
   fuseki:services (
     <#service1>
   ) .

# Custom code.
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .

# TDB
tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
tdb:GraphTDB    rdfs:subClassOf  ja:Model .

## ---------------------------------------------------------------
## Service with only SPARQL query on an inference model.
## Inference model bbase data in TDB.

<#service1>  rdf:type fuseki:Service ;
    fuseki:name              "ds" ;             # http://host/inf
    fuseki:serviceQuery      "sparql" ;          # SPARQL query service
    fuseki:serviceUpdate     "update" ;
    fuseki:serviceQuery             "query" ;
    fuseki:serviceUpload            "upload" ;
    fuseki:serviceReadWriteGraphStore      "data" ;
    # A separate read-only graph store endpoint:
    fuseki:serviceReadGraphStore       "get" ;
    fuseki:dataset           <#dataset> ;
    .

<#dataset> rdf:type       ja:RDFDataset ;
    ja:defaultGraph       <#model_inf> ;
     .

<#model_inf> a ja:InfModel ;
     ja:baseModel <#tdbGraph> ;
     ja:reasoner [
#ja:reasonerURL <http://jena.hpl.hp.com/2003/TransitiveReasoner>
#ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>
#ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMiniFBRuleReasoner>
         ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
     ] .

<#tdbDataset> rdf:type tdb:DatasetTDB ;
    tdb:location "DB" ;
    # If the unionDefaultGraph is used, then the "update" service should be
removed.
    # The unionDefaultGraph is read only.
    #tdb:unionDefaultGraph true ;
    .

<#tdbGraph> rdf:type tdb:GraphTDB ;
    tdb:dataset <#tdbDataset> .



Re: transitive reasoning and named graphs

Posted by Andy Seaborne <an...@apache.org>.
On 10/10/13 11:39, Guy Laden wrote:
> Andy, Thank you for the reply. In our use case the set of graphs in the
> dataset is not known beforehand so we wouldn't be able to configure
> Fuseki ahead of time in the way you outlined.  Is a more dynamic approach
> possible in the context of Fuseki?

Is the set of graphs changing within gthe run of Fuseki?  If it is 
fixed, then you could query the datset to find the graph, and 
autogenerate the configuration file.

> One work around we've discussed is to store do the inference on an
> in-memory model and then store the materialized graph in Fuseki.
> How does this sound to you?

Sounds like a good plan.  It has various efficency advantages but 
assumes the set of graphs is fixed.

(even if TDB had inference, it would not be OWLFBRuleReasoner)

	Andy

> Thanks, Guy
>
>
>
> From:	Andy Seaborne <an...@apache.org>
> To:	users@jena.apache.org,
> Date:	09/10/2013 06:05 PM
> Subject:	Re: transitive reasoning and named graphs
>
>
>
>   > <#dataset> rdf:type       ja:RDFDataset ;
>   >      ja:defaultGraph       <#model_inf> ;
>   >       .
>   >
>   > <#model_inf> a ja:InfModel ;
>   >       ja:baseModel <#tdbGraph> ;
>   >       ja:reasoner [
>   > #ja:reasonerURL <http://jena.hpl.hp.com/2003/TransitiveReasoner>
>   > #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>
>   > #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMiniFBRuleReasoner>
>   >           ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
>   >       ] .
>
>   > <#tdbGraph> rdf:type tdb:GraphTDB ;
>   >      tdb:dataset <#tdbDataset> .
>
> You have the inference engine only over the default graph.
>
> If you point <#tdbGraph> to a different graph it should work.  It will
> appear as the default graph of the dataset, unless you change
> ja:defaultGraph to
> ja:namedGraph [ ja:graph <#yourgraph> ; ja:graphName <http://whatever> ]
>
> 		 Andy
>
> On 09/10/13 13:36, Guy Laden wrote:
>>
>> We are running into an issue trying to use reasoning with Fuseki over
>> owl:TransitiveProperties.
>>
>> Our example (below) works when the triples are uploaded into the default
>> graph but when we upload them to a named graph reasoning doesn't seem to
>> work. (We have tried querying both the named graph and the default graph)
>>
>> The triples
>> --------------
>> <http://localhost/onto#prop1> a
>> <http://www.w3.org/2002/07/owl#TransitiveProperty> .
>> <http://localhost:9090/part1> <http://localhost/onto#prop1>
>> <http://localhost:9090/part2> .
>> <http://localhost:9090/part2> <http://localhost/onto#prop1>
>> <http://localhost:9090/part3> .
>> <http://localhost:9090/part3> <http://localhost/onto#prop1>
>> <http://localhost:9090/part4> .
>>
>> The query
>> -------------
>> SELECT DISTINCT * where {
>> {
>> GRAPH ?g {
>>    <http://localhost:9090/part1> <http://localhost/onto#prop1> ?part .
>> }
>> } UNION {
>> <http://localhost:9090/part1> <http://localhost/onto#prop1> ?part .
>> }
>> }
>>
>> When we upload to some named graph we get no results (even if
>> unionDefaultGraph is set to true)
>>
>> When we upload to the default graph the results we get are:
>> | part                          |
>> =================================
>> | <http://localhost:9090/part2> |
>> | <http://localhost:9090/part3> |
>> | <http://localhost:9090/part4> |
>> ---------------------------------
>>
>> We tried the query like above, with the UNION, as well as with each
> variant
>> separately.
>>
>> We have tried both fuseki 1.0.0 and 0.2.7
>>
>> Below is the Fuseki config file we are using.
>>
>> What are we missing?
>>
>> Thanks, Guy
>>
>> ------------------------
>>
>> @prefix :        <#> .
>> @prefix fuseki:  <http://jena.apache.org/fuseki#> .
>> @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.hpl.hp.com/2008/tdb#> .
>> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
>>
>> [] rdf:type fuseki:Server ;
>>      fuseki:services (
>>        <#service1>
>>      ) .
>>
>> # Custom code.
>> [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
>>
>> # TDB
>> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
>> tdb:GraphTDB    rdfs:subClassOf  ja:Model .
>>
>> ## ---------------------------------------------------------------
>> ## Service with only SPARQL query on an inference model.
>> ## Inference model bbase data in TDB.
>>
>> <#service1>  rdf:type fuseki:Service ;
>>       fuseki:name              "ds" ;             # http://host/inf
>>       fuseki:serviceQuery      "sparql" ;          # SPARQL query service
>>       fuseki:serviceUpdate     "update" ;
>>       fuseki:serviceQuery             "query" ;
>>       fuseki:serviceUpload            "upload" ;
>>       fuseki:serviceReadWriteGraphStore      "data" ;
>>       # A separate read-only graph store endpoint:
>>       fuseki:serviceReadGraphStore       "get" ;
>>       fuseki:dataset           <#dataset> ;
>>       .
>>
>> <#dataset> rdf:type       ja:RDFDataset ;
>>       ja:defaultGraph       <#model_inf> ;
>>        .
>>
>> <#model_inf> a ja:InfModel ;
>>        ja:baseModel <#tdbGraph> ;
>>        ja:reasoner [
>> #ja:reasonerURL <http://jena.hpl.hp.com/2003/TransitiveReasoner>
>> #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>
>> #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMiniFBRuleReasoner>
>>            ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
>>        ] .
>>
>> <#tdbDataset> rdf:type tdb:DatasetTDB ;
>>       tdb:location "DB" ;
>>       # If the unionDefaultGraph is used, then the "update" service should
> be
>> removed.
>>       # The unionDefaultGraph is read only.
>>       #tdb:unionDefaultGraph true ;
>>       .
>>
>> <#tdbGraph> rdf:type tdb:GraphTDB ;
>>       tdb:dataset <#tdbDataset> .
>>
>>
>
>
>


Re: transitive reasoning and named graphs

Posted by Guy Laden <LA...@il.ibm.com>.
Andy, Thank you for the reply. In our use case the set of graphs in the
dataset is not known beforehand so we wouldn't be able to configure
Fuseki ahead of time in the way you outlined.  Is a more dynamic approach
possible in the context of Fuseki?
One work around we've discussed is to store do the inference on an
in-memory model and then store the materialized graph in Fuseki.
How does this sound to you?
Thanks, Guy



From:	Andy Seaborne <an...@apache.org>
To:	users@jena.apache.org,
Date:	09/10/2013 06:05 PM
Subject:	Re: transitive reasoning and named graphs



 > <#dataset> rdf:type       ja:RDFDataset ;
 >      ja:defaultGraph       <#model_inf> ;
 >       .
 >
 > <#model_inf> a ja:InfModel ;
 >       ja:baseModel <#tdbGraph> ;
 >       ja:reasoner [
 > #ja:reasonerURL <http://jena.hpl.hp.com/2003/TransitiveReasoner>
 > #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>
 > #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMiniFBRuleReasoner>
 >           ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
 >       ] .

 > <#tdbGraph> rdf:type tdb:GraphTDB ;
 >      tdb:dataset <#tdbDataset> .

You have the inference engine only over the default graph.

If you point <#tdbGraph> to a different graph it should work.  It will
appear as the default graph of the dataset, unless you change
ja:defaultGraph to
ja:namedGraph [ ja:graph <#yourgraph> ; ja:graphName <http://whatever> ]

		 Andy

On 09/10/13 13:36, Guy Laden wrote:
>
> We are running into an issue trying to use reasoning with Fuseki over
> owl:TransitiveProperties.
>
> Our example (below) works when the triples are uploaded into the default
> graph but when we upload them to a named graph reasoning doesn't seem to
> work. (We have tried querying both the named graph and the default graph)
>
> The triples
> --------------
> <http://localhost/onto#prop1> a
> <http://www.w3.org/2002/07/owl#TransitiveProperty> .
> <http://localhost:9090/part1> <http://localhost/onto#prop1>
> <http://localhost:9090/part2> .
> <http://localhost:9090/part2> <http://localhost/onto#prop1>
> <http://localhost:9090/part3> .
> <http://localhost:9090/part3> <http://localhost/onto#prop1>
> <http://localhost:9090/part4> .
>
> The query
> -------------
> SELECT DISTINCT * where {
> {
> GRAPH ?g {
>   <http://localhost:9090/part1> <http://localhost/onto#prop1> ?part .
> }
> } UNION {
> <http://localhost:9090/part1> <http://localhost/onto#prop1> ?part .
> }
> }
>
> When we upload to some named graph we get no results (even if
> unionDefaultGraph is set to true)
>
> When we upload to the default graph the results we get are:
> | part                          |
> =================================
> | <http://localhost:9090/part2> |
> | <http://localhost:9090/part3> |
> | <http://localhost:9090/part4> |
> ---------------------------------
>
> We tried the query like above, with the UNION, as well as with each
variant
> separately.
>
> We have tried both fuseki 1.0.0 and 0.2.7
>
> Below is the Fuseki config file we are using.
>
> What are we missing?
>
> Thanks, Guy
>
> ------------------------
>
> @prefix :        <#> .
> @prefix fuseki:  <http://jena.apache.org/fuseki#> .
> @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.hpl.hp.com/2008/tdb#> .
> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
>
> [] rdf:type fuseki:Server ;
>     fuseki:services (
>       <#service1>
>     ) .
>
> # Custom code.
> [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
>
> # TDB
> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> tdb:GraphTDB    rdfs:subClassOf  ja:Model .
>
> ## ---------------------------------------------------------------
> ## Service with only SPARQL query on an inference model.
> ## Inference model bbase data in TDB.
>
> <#service1>  rdf:type fuseki:Service ;
>      fuseki:name              "ds" ;             # http://host/inf
>      fuseki:serviceQuery      "sparql" ;          # SPARQL query service
>      fuseki:serviceUpdate     "update" ;
>      fuseki:serviceQuery             "query" ;
>      fuseki:serviceUpload            "upload" ;
>      fuseki:serviceReadWriteGraphStore      "data" ;
>      # A separate read-only graph store endpoint:
>      fuseki:serviceReadGraphStore       "get" ;
>      fuseki:dataset           <#dataset> ;
>      .
>
> <#dataset> rdf:type       ja:RDFDataset ;
>      ja:defaultGraph       <#model_inf> ;
>       .
>
> <#model_inf> a ja:InfModel ;
>       ja:baseModel <#tdbGraph> ;
>       ja:reasoner [
> #ja:reasonerURL <http://jena.hpl.hp.com/2003/TransitiveReasoner>
> #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>
> #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMiniFBRuleReasoner>
>           ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
>       ] .
>
> <#tdbDataset> rdf:type tdb:DatasetTDB ;
>      tdb:location "DB" ;
>      # If the unionDefaultGraph is used, then the "update" service should
be
> removed.
>      # The unionDefaultGraph is read only.
>      #tdb:unionDefaultGraph true ;
>      .
>
> <#tdbGraph> rdf:type tdb:GraphTDB ;
>      tdb:dataset <#tdbDataset> .
>
>




Re: transitive reasoning and named graphs

Posted by Andy Seaborne <an...@apache.org>.
 > <#dataset> rdf:type       ja:RDFDataset ;
 >      ja:defaultGraph       <#model_inf> ;
 >       .
 >
 > <#model_inf> a ja:InfModel ;
 >       ja:baseModel <#tdbGraph> ;
 >       ja:reasoner [
 > #ja:reasonerURL <http://jena.hpl.hp.com/2003/TransitiveReasoner>
 > #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>
 > #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMiniFBRuleReasoner>
 >           ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
 >       ] .

 > <#tdbGraph> rdf:type tdb:GraphTDB ;
 >      tdb:dataset <#tdbDataset> .

You have the inference engine only over the default graph.

If you point <#tdbGraph> to a different graph it should work.  It will 
appear as the default graph of the dataset, unless you change 
ja:defaultGraph to
ja:namedGraph [ ja:graph <#yourgraph> ; ja:graphName <http://whatever> ]

	Andy

On 09/10/13 13:36, Guy Laden wrote:
>
> We are running into an issue trying to use reasoning with Fuseki over
> owl:TransitiveProperties.
>
> Our example (below) works when the triples are uploaded into the default
> graph but when we upload them to a named graph reasoning doesn't seem to
> work. (We have tried querying both the named graph and the default graph)
>
> The triples
> --------------
> <http://localhost/onto#prop1> a
> <http://www.w3.org/2002/07/owl#TransitiveProperty> .
> <http://localhost:9090/part1> <http://localhost/onto#prop1>
> <http://localhost:9090/part2> .
> <http://localhost:9090/part2> <http://localhost/onto#prop1>
> <http://localhost:9090/part3> .
> <http://localhost:9090/part3> <http://localhost/onto#prop1>
> <http://localhost:9090/part4> .
>
> The query
> -------------
> SELECT DISTINCT * where {
> {
> GRAPH ?g {
>   <http://localhost:9090/part1> <http://localhost/onto#prop1> ?part .
> }
> } UNION {
> <http://localhost:9090/part1> <http://localhost/onto#prop1> ?part .
> }
> }
>
> When we upload to some named graph we get no results (even if
> unionDefaultGraph is set to true)
>
> When we upload to the default graph the results we get are:
> | part                          |
> =================================
> | <http://localhost:9090/part2> |
> | <http://localhost:9090/part3> |
> | <http://localhost:9090/part4> |
> ---------------------------------
>
> We tried the query like above, with the UNION, as well as with each variant
> separately.
>
> We have tried both fuseki 1.0.0 and 0.2.7
>
> Below is the Fuseki config file we are using.
>
> What are we missing?
>
> Thanks, Guy
>
> ------------------------
>
> @prefix :        <#> .
> @prefix fuseki:  <http://jena.apache.org/fuseki#> .
> @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.hpl.hp.com/2008/tdb#> .
> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
>
> [] rdf:type fuseki:Server ;
>     fuseki:services (
>       <#service1>
>     ) .
>
> # Custom code.
> [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
>
> # TDB
> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> tdb:GraphTDB    rdfs:subClassOf  ja:Model .
>
> ## ---------------------------------------------------------------
> ## Service with only SPARQL query on an inference model.
> ## Inference model bbase data in TDB.
>
> <#service1>  rdf:type fuseki:Service ;
>      fuseki:name              "ds" ;             # http://host/inf
>      fuseki:serviceQuery      "sparql" ;          # SPARQL query service
>      fuseki:serviceUpdate     "update" ;
>      fuseki:serviceQuery             "query" ;
>      fuseki:serviceUpload            "upload" ;
>      fuseki:serviceReadWriteGraphStore      "data" ;
>      # A separate read-only graph store endpoint:
>      fuseki:serviceReadGraphStore       "get" ;
>      fuseki:dataset           <#dataset> ;
>      .
>
> <#dataset> rdf:type       ja:RDFDataset ;
>      ja:defaultGraph       <#model_inf> ;
>       .
>
> <#model_inf> a ja:InfModel ;
>       ja:baseModel <#tdbGraph> ;
>       ja:reasoner [
> #ja:reasonerURL <http://jena.hpl.hp.com/2003/TransitiveReasoner>
> #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>
> #ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMiniFBRuleReasoner>
>           ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
>       ] .
>
> <#tdbDataset> rdf:type tdb:DatasetTDB ;
>      tdb:location "DB" ;
>      # If the unionDefaultGraph is used, then the "update" service should be
> removed.
>      # The unionDefaultGraph is read only.
>      #tdb:unionDefaultGraph true ;
>      .
>
> <#tdbGraph> rdf:type tdb:GraphTDB ;
>      tdb:dataset <#tdbDataset> .
>
>