Reasoning with Fuseki, TDB and named graphs?

I maintain a dataset containing 10-20 named graphs from a TDB dataset in Fuseki 2. I would like to use argumentation to output to my data. The behavior that I would like to see is that triples should appear in each chart, which should be displayed inside these charts (although it would be nice if the triples also appeared on the chart by default). Is there an easy way to configure this? I have not found configuration examples that match what I am trying to do.

The configuration I tried is very similar to the following standard example.

DatasetTDB โ†’ GraphTDB โ†’ InfModel โ†’ RDFDataset

The final view of the data that I see is just a very small subset of the data (it seems that all of the named graphs are discarded somewhere along this pipeline, and only a tiny default graph remains). Using tdb: unionDefaultGraph does not seem to affect this.

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#> . # Example of a data service with SPARQL query and update on an # inference model. Data is taken from TDB. ## --------------------------------------------------------------- ## Service with only SPARQL query on an inference model. ## Inference model base data is in TDB. <#service2> rdf:type fuseki:Service ; fuseki:name "inf" ; # http://host/inf fuseki:serviceQuery "sparql" ; # SPARQL query service fuseki:serviceUpdate "update" ; 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> ] . ## Base data in TDB. <#tdbDataset> rdf:type tdb:DatasetTDB ; tdb:location "DB" ; # If the unionDefaultGraph is used, then the "update" service should be removed. # tdb:unionDefaultGraph true ; . <#tdbGraph> rdf:type tdb:GraphTDB ; tdb:dataset <#tdbDataset> . </code> 

Does anyone have any thoughts on this?

In addition, bonus points, if there is a way to make the data set writable. (At some level, I'm trying to approach the default behavior of Owlim / GraphDB, which preserves constant graphic names, infers, and also allows updating.)

Thanks in advance.

+5
source share
3 answers

I am facing (or encountering) the same problems with my code, but I have a partial solution. Unfortunately, the link contained in the comments didnโ€™t really help those problems that I still encounter, but this answers part of the problem.

The final view of the data that I see is just a very small subset of the data (it seems that all named graphs are discarded somewhere along this pipeline, and only a tiny default graph remains). Using tdb: unionDefaultGraph does not seem to affect this.

The workaround I found for this is to explicitly โ€œregisterโ€ your named graphs in the configuration file. I really don't know if this is the best way (and have not found any documentation or example for this exact context). A working example of my installation (Fuseki 2.4):

 [usual configuration start] # TDB Dataset :tdb_dataset_readwrite a tdb:DatasetTDB ; tdb:unionDefaultGraph true ; #if you want all data to available in the default graph #without 'FROM-NAMing them' in the SPARQL query tdb:location "your/dataset/path" . # Underlying RDF Dataset <#dataset> rdf:type ja:RDFDataset ; ja:defaultGraph <#model> ; ja:namedGraph [ ja:graphName <your/graph/URI> ; ja:graph <#graphVar> ] ; [repeat for other named graphs] . ###### # Default Model : Inference rules (OWL, here) <#model> a ja:InfModel; ja:baseModel <#tdbGraph>; ja:reasoner [ ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner> ] . # Graph for the default Model <#tdbGraph> rdf:type tdb:GraphTDB; tdb:dataset :tdb_dataset_readwrite . ###### # Named Graph <#graphVar> rdf:type tdb:GraphTDB ; tdb:dataset :tdb_dataset_readwrite ; tdb:graphName <your/graph/URI> . 

Then you can run a query like this

 [prefixes] SELECT ?graph ?predicate ?object WHERE { GRAPH ?graph {[a specific entity identifier] ?predicate ?object} } LIMIT 50 

And it will display (in this case) the properties and values โ€‹โ€‹and the source graph where they were found.

BUT: in this example, even if the default graph supposedly imported output rules (which should be applied globally, especially since the unionDefaultGraph parameter is enabled), they are not applied as a โ€œcross-graphโ€, and this is a problem that I still encounter .

Usually, if you add an output engine to each chart, this should work, according to Andy Seaborn's post here , but it doesn't work that way in my case.

Hope this helps anyway.

+1
source

I have come across this problem many times, but in fact I have never seen a solution. However, I managed to figure this out after reading this in the documentation about the "special graph names" in TDB datasets. As I understand it, setting the default join graph for a TDB dataset in an assembler file only changes what is returned when a specific dataset is requested. However, there is a special graph name that can be used to refer to the union graph: <urn:x-arq:UnionGraph> . So, just create GraphTDB , GraphTDB at the TDB dataset and point it to this special graph.

Below is the configuration file that is requested in the question: the reasoning is performed according to the union column by default, and the result is displayed in the TDB dataset as a recordable service. (Please note that the reasoning service will not see any changes in the data set until it is restarted, since everything is done in the memory).

 @prefix : <http://base/#> . @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#> . @prefix fuseki: <http://jena.apache.org/fuseki#> . # TDB tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset . tdb:GraphTDB rdfs:subClassOf ja:Model . # Service 1: Dataset endpoint (no reasoning) :dataService a fuseki:Service ; fuseki:name "tdbEnpoint" ; fuseki:serviceQuery "sparql", "query" ; fuseki:serviceUpdate "update" ; fuseki:dataset :tdbDataset ; . # Service 2: Reasoning endpoint :reasoningService a fuseki:Service ; fuseki:dataset :infDataset ; fuseki:name "reasoningEndpoint" ; fuseki:serviceQuery "query", "sparql" ; fuseki:serviceReadGraphStore "get" ; . # Inference dataset :infDataset rdf:type ja:RDFDataset ; ja:defaultGraph :infModel ; . # Inference model :infModel a ja:InfModel ; ja:baseModel :g ; ja:reasoner [ ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner> ; ] ; . # Intermediate graph referencing the default union graph :g rdf:type tdb:GraphTDB ; tdb:dataset :tdbDataset ; tdb:graphName <urn:x-arq:UnionGraph> ; . # The location of the TDB dataset :tdbDataset rdf:type tdb:DatasetTDB ; tdb:location "/fuseki/databases/db" ; tdb:unionDefaultGraph true ; . 
+1
source

I use a similar configuration, and although I try to add a named graph during the web interface, I get an error

 Result: failed with message "Read-only object file" 

Has anyone encountered such an error? I already checked all the permissions set in the DatasetTDB location event for all 777, but still have the same error. If I upload a file for the default chart, everything is fine.

0
source

Source: https://habr.com/ru/post/1273762/


All Articles