Hi Andy,

I'm trying to use the TDB Java API so without Fuseki or command line.
The assembler is in a file passed to the TDB factory method.
Below is the example I was working from for reference 
(https://jena.apache.org/documentation/tdb/java_api.html):

String assemblerFile = "Store/tdb-assembler.ttl";
Dataset dataset = TDBFactory.assembleDataset(assemberFile);

Sorry for the confusion. I referred to Fuseki as there seem to be more examples 
which use assembler than for just TDB.
As you suggested I've added an RDFDataset to bring the models together but 
still no RDFS result.

Example:

<#dataset> rdf:type       ja:RDFDataset ;
    ja:namedGraph       :my-model-inf1 ;
    ja:namedGraph       :my-model-inf2 .

I can query the dataset for an asserted property but an inferred property isn't 
returned.
The test queries are successful when I use the Inference API approach to create 
a single InfModel so that shouldn't be the problem.

The other possible issue with the assembler content is loading the schema from 
file.
I've queried for properties contained in the schema and not in the data but 
they aren't showing either.
Deliberately entering an incorrect schema path gives no errors or warnings so 
it could be that the schema loading is silently failing.
The assembler loading throws syntax errors but nothing for the missing file.
Is there a way to confirm that the schema loads correctly?

Thanks,

Greg

-----Original Message-----
From: Andy Seaborne <a...@apache.org> 
Sent: 04 April 2018 10:11
To: users@jena.apache.org
Subject: Re: TDB Assembly: Multiple Named Graphs with RDFS Inferencing

Hi Greg,

Just to check:
How are you running the server?
Is that assembler on the command line?

-----

When Fuseki starts up it looks for datasets by rdf:type.

In your assembler below there is one dataset:

 > #TDB dataset on disk.
 > :tdb-dataset rdf:type tdb:DatasetTDB ;
 >      tdb:location  "my_jena_tdb" .

and that is what Fuseki will find.

The rest of the assembler isn't connected to that.

You need two datasets - one to pull your graphs and inference together, and a 
subsidiary one to have the TDB storage.

Does this example help?

https://github.com/apache/jena/blob/master/jena-fuseki2/examples/service-inference-2.ttl

     Andy

On 03/04/18 15:14, Greg Albiston wrote:
> Hello,
> 
> I'm trying to setup a TDB dataset that contains multiple named graphs which 
> each use RDFS inferencing and a schema.
> I've tried to follow the website documentation but there are several gaps on 
> this topic.
> For example, the RDFS section on 
> https://jena.apache.org/documentation/tdb/assembler.html and the Inference 
> section on 
> https://jena.apache.org/documentation/fuseki2/fuseki-configuration.html don't 
> seem to contain complete information.
> 
> The objective is that when using the Jena API a single Dataset object can be 
> retrieved to execute queries against. The queries themselves will specify the 
> graph to be selected.
> 
> I've tried a variant on the below which runs without error. The schema file 
> and TDB folder are both located in the root of the application folder. 
> However, a test query on the dataset for the named graph provides asserted 
> results but not RDFS inferencing. I've confirmed through debugging that the 
> assembly file is loaded.
> 
> Does a URI name need to be set for the inference model for referencing?
> The below webpage has an example for Fuseki with persistent TDB and 
> inferencing. It has a ja:RDFDataset that states the ja:defaultGraph as being 
> the inference model. Is the same required for named graphs?
> https://christinemdraper.wordpress.com/2017/04/09/getting-started-with
> -rdf-sparql-jena-fuseki/
> 
> Any help would be much appreciated,
> 
> Greg
> 
> @prefix :      <http://example.org/my#> .
> @prefix tdb:   <http://jena.hpl.hp.com/2008/tdb#> .
> @prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix ja:    <http://jena.hpl.hp.com/2005/11/Assembler#> .
> @prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
> 

> [] ja:loadClass "org.apache.jena.tdb.TDB" .
> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> tdb:GraphTDB    rdfs:subClassOf  ja:Model      .

This isn't necessary nowadays - it's harmless.


> 
> #TDB dataset on disk.
> :tdb-dataset rdf:type tdb:DatasetTDB ;
>      tdb:location  "my_jena_tdb" .
> 
> #Create a RDFS Factory as re-used.
> :rdfsFactory rdf:type ja:ReasonerFactory;
>      ja:reasonerURL <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner>;
>      ja:schema :myRDFS .
> 
> #RDFS Schema loaded as memory model.
> :myRDFS rdf:type ja:MemoryModel ;
>      ja:content [ja:externalContent <file:///my_schema.rdf>] .
> 
> #Specify named graph in the dataset.
> :my-graph rdf:type tdb:GraphTDB ;
>      tdb:dataset :tdb-dataset ;
>      tdb:graphName <http://example.org#myGraph> .
> 
> #Inference model combining graph and reasoner.
> :my-model-inf rdf:type ja:InfModel ;
>      ja:baseModel :my-graph ;
>      ja:reasoner :rdfsFactory.
> 

Reply via email to