使用TDB2和OWL Reasoner配置fuseki

时间:2018-02-13 15:54:14

标签: rdf jena owl fuseki

这里是fuseki / jena的新手。我设法使用tdb1使用oWLFBRuleReasoner运行fuseki没有问题,但无法使其与tdb2(http://jena.apache.org/2016/tdb#)一起使用。我找不到使用TDB2和OWLFBRuleReasoner的配置的明确示例,所以我刚刚转换了这个(有效)

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

(这个工作正常。我用猫头鹰测试:inverseOf属性)

进入这个(不起作用)

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

正如您所看到的,我基本上只是将tdb替换为tdb2(名称空间和全部)。 Fuseki启动并运行正常,但OWL推断不起作用。

任何人都可以向我指出相关文档/示例?或者我完全误解了TDB1与TDB2的交易。

谢谢你

编辑:修复了我的TDB2配置文件(仍然无效)。

2 个答案:

答案 0 :(得分:0)

以下适用于我:

@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]" .

与您的版本的主要区别在于没有推理的单独数据集(而不是已经注意到的循环'Barry NL')以及tdb前缀的不同命名空间。请注意,名称空间前缀可以自由选择(它们没有语义含义),只要它指向相同的名称空间URL,更改名称空间前缀就无关紧要了。

答案 1 :(得分:0)

这是我的工作

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