configure fuseki with TDB2 and OWL Reasoner

浪子不回头ぞ 提交于 2020-03-23 04:27:06

问题


New to fuseki/jena here. I managed to get fuseki to run with OWLFBRuleReasoner using tdb1 no problem, but can't make it work with tdb2 (http://jena.apache.org/2016/tdb#). I could not find an explicit example of configuration that uses both TDB2 and OWLFBRuleReasoner, so I just converted this one (that works)

    @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#> .

# fuseki configuration to have OWL entailment
# this is the configuration on s-stf-gin (fuseki data folder is on c:\)

:service_tdb_all  a                   fuseki:Service ;
        rdfs:label                    "TDB gsip" ;
        fuseki:dataset                :tdb_dataset_readwrite ;
        fuseki:name                   "gsip" ; 
        fuseki:serviceQuery           "query" , "sparql" ;
        fuseki:serviceReadGraphStore  "get" ;
        fuseki:serviceReadWriteGraphStore
                "data" ; 
        fuseki:serviceUpdate          "update" ; 
        fuseki:serviceUpload          "upload" . 

        # above, remove data, update and upload in prod
:tdb_dataset_readwrite
        a             ja:RDFDataset;
        rdfs:label "GSIP";
        ja:defaultGraph       <#model_inf> ;
        tdb:location  "c:\\fuseki/databases/gsip" .

<#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 .

(this one works fine. I tested with a owl:inverseOf property)

into this one (that does not work)

@prefix :      <http://base/#> .
@prefix tdb2:   <http://jena.apache.org/2016/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#> .

:service_tdb_all  a                   fuseki:Service ;
        fuseki:dataset                :dataset ;
        fuseki:name                   "gsip" ;
        fuseki:serviceQuery           "query" , "sparql" ;
        fuseki:serviceReadGraphStore  "get" ;
        fuseki:serviceReadWriteGraphStore "data" ;
        fuseki:serviceUpdate          "update" ;
        fuseki:serviceUpload          "upload" .

:dataset a ja:RDFDataset ;
    ja:defaultGraph       <#model_inf> ;
    tdb2:location  "c:\\fuseki/databases/gsip"
     .

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

<#graph> rdf:type tdb2:GraphTDB ; # also tried tdb2:GraphTDB2
  tdb2:dataset :dataset .

As you can see, I basically just replace tdb with tdb2 (namespaces and all). Fuseki starts and runs fine, but OWL inference does not work.

Anyone can point me to relevant documentation / example ? or maybe I totally misunderstood TDB1 vs TDB2 deal.

Thanks you

EDIT: fixed my TDB2 configuration file (still does not work).


回答1:


The following works for me:

@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#> .

:service_tdb_all  a                   fuseki:Service ;
        rdfs:label                    "TDB [MyDatasetName]" ;
        fuseki:dataset                :inferred_dataset ;
        fuseki:name                   "[MyDatasetName]" ;
        fuseki:serviceQuery           "query" , "sparql" ;
        fuseki:serviceReadGraphStore  "get" ;
        fuseki:serviceReadWriteGraphStore
                "data" ;
        fuseki:serviceUpdate          "update" ;
        fuseki:serviceUpload          "upload" .

:inferred_dataset a ja:RDFDataset ;
        ja:defaultGraph :inference_model .

:inference_model a ja:InfModel ;
        ja:baseModel :tdb_graph ;
        ja:reasoner [
                ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>
        ] .

:tdb_graph a tdb:GraphTDB ;
        tdb:dataset :tdb_dataset_readwrite .

:tdb_dataset_readwrite
        a             tdb:DatasetTDB ;
        tdb:location  "[MyDatasetLocationOnDisk]" .

Main differences with your version are a separate dataset without inference (instead of the loop back 'Barry NL' already noticed) and a different namespace for the tdb prefix. Note that namespace prefixes are free to choose (they have no semantic meaning), and changing a namespace prefix does not matter as long as it points to the same namespace URL.




回答2:


This is my work:

@prefix :      <http://base/#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix tdb2:  <http://jena.apache.org/2016/tdb#> .
@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#> .

:service_tdb_all  a                   fuseki:Service ;
        rdfs:label                    "TDB2 food" ;
        fuseki:dataset                :tdb_dataset_readwrite ;
        fuseki:name                   "food" ;
        fuseki:serviceQuery           "query" , "sparql" ;
        fuseki:serviceReadGraphStore  "get" ;
        fuseki:serviceReadWriteGraphStore
                "data" ;
        fuseki:serviceUpdate          "update" ;
        fuseki:serviceUpload          "upload" .

:tdb_dataset_readwrite a ja:RDFDataset;
		ja:defaultGraph :modelInf;
		.

:modelInf a ja:InfModel;
		ja:reasoner [ ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>] ;
		#ja:reasoner [ ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ; 
                     # ja:rulesFrom <file:///C:/Users/shaoj/Documents/IntelligentQA/apache-jena-fuseki-3.8.0/run/databases/rules.ttl> ] ;
		ja:baseModel :gra ;
		.
:gra a tdb2:GraphTDB;
        tdb2:location  "C:\\Users\\shaoj\\Documents\\IntelligentQA\\apache-jena-fuseki-3.8.0\\run/databases/food" ;
		tdb2:unionDefaultGraph true ; 
		.


来源:https://stackoverflow.com/questions/48770691/configure-fuseki-with-tdb2-and-owl-reasoner

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!