You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Niclas Hoyer <ni...@verbugt.de> on 2013/03/20 22:21:17 UTC
Fuseki + union default graph + reasoning
Hi,
I try to get a TDB dataset with a union default graph and a reasoner to
work.
For a simple TDB dataset with a union default graph I used:
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
<#dataset> a tdb:DatasetTDB ;
tdb:location "ds" ;
tdb:unionDefaultGraph true .
For reasoning with TDB I used:
<#dataset> a ja:RDFDataset ;
ja:defaultGraph <#model> .
<#model> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
] .
<#tdbGraph> a tdb:GraphTDB ;
tdb:location "ds" .
Now I have no clue how to bring them together. The domain of
tdb:unionDefaultGraph is tdb:DatasetTDB, but the example with reasoning
uses ja:RDFDataset.
Is it even possible to use reasoning with a union default graph?
Regards,
Niclas
Re: Fuseki + union default graph + reasoning
Posted by Andy Seaborne <an...@apache.org>.
On 20/03/13 22:08, Niclas Hoyer wrote:
> Thank you very much for the quick reply and the complete example!
>
> Is it also possible to use SPARQL 1.1 UPDATE requests with this setup?
I don't think so.
If you update the base dataset directly (additional service in Fuseki),
the base data changes but the inference engine will not see that until a
restart.
If you update the inference model, the problem is that union graph is
read-only.
If it was a union default graph, you can update via the inference model.
If you update the dataset for the inference setup as a named graph, it
isn't the named graph of the base datasets.
Andy
>
> I added the following to the service description:
>
> fuseki:serviceUpdate "update" ;
> fuseki:serviceReadWriteGraphStore "data" ;
>
> and inserted some data into a named graph (e.g. "Example 2" from the
> SPARQL 1.1 spec):
>
> PREFIX dc: <http://purl.org/dc/elements/1.1/>
> PREFIX ns: <http://example.org/ns#>
> INSERT DATA
> { GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 } }
>
> I expected the triple to be visible in the default graph, but I get no
> result for the following query:
>
> PREFIX ns: <http://example.org/ns#>
> SELECT ?x ?p WHERE { ?x ns:price ?p }
>
> Is this intended? Maybe I misunderstood the meaning of a union default
> graph.
>
> Regards,
> Niclas
>
> Am 20.03.2013 22:43, schrieb Andy Seaborne:
>> On 20/03/13 21:21, Niclas Hoyer wrote:
>>> Hi,
>>>
>>> I try to get a TDB dataset with a union default graph and a reasoner to
>>> work.
>>>
>>> For a simple TDB dataset with a union default graph I used:
>>>
>>> tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
>>> <#dataset> a tdb:DatasetTDB ;
>>> tdb:location "ds" ;
>>> tdb:unionDefaultGraph true .
>>>
>>> For reasoning with TDB I used:
>>>
>>> <#dataset> a ja:RDFDataset ;
>>> ja:defaultGraph <#model> .
>> >
>>> <#model> a ja:InfModel ;https://svn.apache.org/repos/asf/jena/site/trunk/
>>> ja:baseModel <#tdbGraph> ;
>>> ja:reasoner [
>>> ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
>>> ] .
>>> <#tdbGraph> a tdb:GraphTDB ;
>>> tdb:location "ds" .
>>>
>>> Now I have no clue how to bring them together. The domain of
>>> tdb:unionDefaultGraph is tdb:DatasetTDB, but the example with reasoning
>>> uses ja:RDFDataset.
>>>
>>> Is it even possible to use reasoning with a union default graph?
>>
>> You don't need to bring the <#datasets> together.
>>
>> <#dataset> a ja:RDFDataset ;
>>
>> is fine - a general purpose, in-memory dataset to hold the inference
>> and be the target for the query.
>>
>> You then need to define the base data.
>>
>> <#tdbDataset> rdf:type tdb:DatasetTDB ;
>> tdb:location "ds" ;
>> tdb:unionDefaultGraph true .
>>
>> <#tdbGraph> rdf:type tdb:GraphTDB ;
>> tdb:dataset <#dataset> .
>>
>> i.e. the TDB dataset is only there to hook the TDB graph into the system.
>>
>> You'll need to use <#dataset> in the service.
>>
>> Full example:
>> -------------------------------------
>> @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 .
>>
>> <#service1> rdf:type fuseki:Service ;
>> fuseki:name "inf" ; # http://host/inf
>> fuseki:serviceQuery "sparql" ; # SPARQL query service
>> 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/OWLFBRuleReasoner>
>> ] .
>>
>> <#tdbDataset> rdf:type tdb:DatasetTDB ;
>> tdb:location "DB" ;
>> tdb:unionDefaultGraph true .
>>
>> <#tdbGraph> rdf:type tdb:GraphTDB ;
>> tdb:dataset <#tdbDataset> .
>> -------------------------------------
>>>
>>> Regards,
>>> Niclas
>
Re: Fuseki + union default graph + reasoning
Posted by Niclas Hoyer <ni...@verbugt.de>.
Thank you very much for the quick reply and the complete example!
Is it also possible to use SPARQL 1.1 UPDATE requests with this setup?
I added the following to the service description:
fuseki:serviceUpdate "update" ;
fuseki:serviceReadWriteGraphStore "data" ;
and inserted some data into a named graph (e.g. "Example 2" from the
SPARQL 1.1 spec):
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX ns: <http://example.org/ns#>
INSERT DATA
{ GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 } }
I expected the triple to be visible in the default graph, but I get no
result for the following query:
PREFIX ns: <http://example.org/ns#>
SELECT ?x ?p WHERE { ?x ns:price ?p }
Is this intended? Maybe I misunderstood the meaning of a union default
graph.
Regards,
Niclas
Am 20.03.2013 22:43, schrieb Andy Seaborne:
> On 20/03/13 21:21, Niclas Hoyer wrote:
>> Hi,
>>
>> I try to get a TDB dataset with a union default graph and a reasoner to
>> work.
>>
>> For a simple TDB dataset with a union default graph I used:
>>
>> tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
>> <#dataset> a tdb:DatasetTDB ;
>> tdb:location "ds" ;
>> tdb:unionDefaultGraph true .
>>
>> For reasoning with TDB I used:
>>
>> <#dataset> a ja:RDFDataset ;
>> ja:defaultGraph <#model> .
> >
>> <#model> a ja:InfModel ;
>> ja:baseModel <#tdbGraph> ;
>> ja:reasoner [
>> ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
>> ] .
>> <#tdbGraph> a tdb:GraphTDB ;
>> tdb:location "ds" .
>>
>> Now I have no clue how to bring them together. The domain of
>> tdb:unionDefaultGraph is tdb:DatasetTDB, but the example with reasoning
>> uses ja:RDFDataset.
>>
>> Is it even possible to use reasoning with a union default graph?
>
> You don't need to bring the <#datasets> together.
>
> <#dataset> a ja:RDFDataset ;
>
> is fine - a general purpose, in-memory dataset to hold the inference
> and be the target for the query.
>
> You then need to define the base data.
>
> <#tdbDataset> rdf:type tdb:DatasetTDB ;
> tdb:location "ds" ;
> tdb:unionDefaultGraph true .
>
> <#tdbGraph> rdf:type tdb:GraphTDB ;
> tdb:dataset <#dataset> .
>
> i.e. the TDB dataset is only there to hook the TDB graph into the system.
>
> You'll need to use <#dataset> in the service.
>
> Full example:
> -------------------------------------
> @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 .
>
> <#service1> rdf:type fuseki:Service ;
> fuseki:name "inf" ; # http://host/inf
> fuseki:serviceQuery "sparql" ; # SPARQL query service
> 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/OWLFBRuleReasoner>
> ] .
>
> <#tdbDataset> rdf:type tdb:DatasetTDB ;
> tdb:location "DB" ;
> tdb:unionDefaultGraph true .
>
> <#tdbGraph> rdf:type tdb:GraphTDB ;
> tdb:dataset <#tdbDataset> .
> -------------------------------------
>>
>> Regards,
>> Niclas
Re: Fuseki + union default graph + reasoning
Posted by Andy Seaborne <an...@apache.org>.
On 20/03/13 21:21, Niclas Hoyer wrote:
> Hi,
>
> I try to get a TDB dataset with a union default graph and a reasoner to
> work.
>
> For a simple TDB dataset with a union default graph I used:
>
> tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
> <#dataset> a tdb:DatasetTDB ;
> tdb:location "ds" ;
> tdb:unionDefaultGraph true .
>
> For reasoning with TDB I used:
>
> <#dataset> a ja:RDFDataset ;
> ja:defaultGraph <#model> .
>
> <#model> a ja:InfModel ;
> ja:baseModel <#tdbGraph> ;
> ja:reasoner [
> ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
> ] .
> <#tdbGraph> a tdb:GraphTDB ;
> tdb:location "ds" .
>
> Now I have no clue how to bring them together. The domain of
> tdb:unionDefaultGraph is tdb:DatasetTDB, but the example with reasoning
> uses ja:RDFDataset.
>
> Is it even possible to use reasoning with a union default graph?
You don't need to bring the <#datasets> together.
<#dataset> a ja:RDFDataset ;
is fine - a general purpose, in-memory dataset to hold the inference and
be the target for the query.
You then need to define the base data.
<#tdbDataset> rdf:type tdb:DatasetTDB ;
tdb:location "ds" ;
tdb:unionDefaultGraph true .
<#tdbGraph> rdf:type tdb:GraphTDB ;
tdb:dataset <#dataset> .
i.e. the TDB dataset is only there to hook the TDB graph into the system.
You'll need to use <#dataset> in the service.
Full example:
-------------------------------------
@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 .
<#service1> rdf:type fuseki:Service ;
fuseki:name "inf" ; # http://host/inf
fuseki:serviceQuery "sparql" ; # SPARQL query service
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/OWLFBRuleReasoner>
] .
<#tdbDataset> rdf:type tdb:DatasetTDB ;
tdb:location "DB" ;
tdb:unionDefaultGraph true .
<#tdbGraph> rdf:type tdb:GraphTDB ;
tdb:dataset <#tdbDataset> .
-------------------------------------
>
> Regards,
> Niclas