自定义JENA FUSEKI规则时table没有可用数据?

No data available in table, when I customize the rules of JENA FUSEKI?

自定义JENA FUSEKI规则时table没有可用数据?

删除rules.ttl开头的@prefix后,如下,

[ruleComedian: (?p :hasActedIn ?m) (?m :hasGenre ?g) (?g :genreName '喜剧') -> (?p rdf:type :Comedian)]
[ruleInverse: (?p :hasActedIn ?m) -> (?m :hasActor ?p)]

更新1:rules.ttl,

最上面的@prefix
@prefix : <http://www.kgdemo.com#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

此外,

I have added fuseki_conf.ttl in the path of D:\AppsPath\apache-jena-fuseki-3.8.0\run\configuration\fuseki_conf.ttl.

fuseki_conf.ttl如下,

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

<#service1> rdf:type fuseki:Service ;
    fuseki:name                       "kg_demo_movie" ;       # http://host:port/ds
    fuseki:serviceQuery               "sparql" ;   # SPARQL query service
    fuseki:serviceQuery               "query" ;    # SPARQL query service (alt name)
    fuseki:serviceUpdate              "update" ;   # SPARQL update service
    fuseki:serviceUpload              "upload" ;   # Non-SPARQL upload service
    fuseki:serviceReadWriteGraphStore "data" ;     # SPARQL Graph store protocol (read and write)
    # A separate read-only graph store endpoint:
    fuseki:serviceReadGraphStore      "get" ;      # SPARQL Graph store protocol (read only)
    fuseki:dataset                   <#dataset> ;
    .


<#movies> rdf:type ja:RDFDataset ;
    rdfs:label "Movies" ;
    ja:defaultGraph
      [ rdfs:label "movies.ttl" ;
        a ja:MemoryModel ;
        ja:content [ja:externalContent <file://D:/AppsPath/apache-jena-fuseki-3.8.0/run/databases/movies.ttl> ] ;
        # 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://D:/AppsPath/apache-jena-fuseki-3.8.0/run/databases/rules.ttl> ];
      ] ;
    .


<#dataset> rdf:type tdb:DatasetTDB ;
    tdb:location "E:/data/tdb" ;
    ja:graph <#movies> ;
    # Query timeout on this dataset (1s, 1000 milliseconds)
    ja:context [ ja:cxtName "arq:queryTimeout" ;  ja:cxtValue "1000" ] ;
    # Make the default graph be the union of all named graphs.
    ## tdb:unionDefaultGraph true ;
    .

不知道我描述清楚没有。


抱歉,我忘了粘贴我的查询代码。

PREFIX : <http://www.kgdemo.com#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?n WHERE {
?x rdf:type :Comedian.
?x :personName ?n.
}
limit 10

最终的SPARQL查询结果为No data available in table.

谢谢。


更新二:规则是我从网上复制过来的(没错)。但是,由于JENA FUSEKI版本已经升级,需要修改fuseki_conf.ttl文件。

我觉得问题应该是我修改的fuseki_conf.ttl不对


更新3:旧的fuseki_conf.ttl(正确)

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


:service1        a                fuseki:Service ;
fuseki:dataset                    <#dataset> ;
fuseki:name                       "kg_demo_movie" ;
fuseki:serviceQuery               "query" , "sparql" ;
fuseki:serviceReadGraphStore      "get" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceUpdate              "update" ;
fuseki:serviceUpload              "upload" .


<#dataset> rdf:type ja:RDFDataset ;
    ja:defaultGraph <#model_inf> ;
    .

<#model_inf> a ja:InfModel ;
    ja:baseModel <#tdbGraph> ;

    ja:content [ja:externalContent <file:///D:/apache%20jena/apache-jena-fuseki-3.5.0/run/databases/ontology.ttl> ] ;

    #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:///D:/apache%20jena/apache-jena-fuseki-3.5.0/run/databases/rules.ttl> ; ]
    .

<#tdbGraph> rdf:type tdb:GraphTDB ;
    tdb:dataset <#tdbDataset> ;
    .

<#tdbDataset> rdf:type tdb:DatasetTDB ;
    tdb:location "D:/apache jena/tdb_for_demo" ;

现在效果很好。

谢谢。

第 1 步:fuseki_conf.ttl

@prefix tdb:   <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja:    <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .

<#service1> rdf:type fuseki:Service ;
    fuseki:name                       "kg_demo_movie" ;     
    fuseki:serviceQuery               "sparql", "query" ; 
    fuseki:serviceReadGraphStore      "get" ;
    fuseki:dataset                   <#dataset> ;
    .

<#dataset> rdf:type ja:RDFDataset ;
    ja:defaultGraph <#modelInf> ;
    .

<#modelInf> rdf:type ja:InfModel ;
    ja:reasoner [ ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ; 
                  ja:rulesFrom <file:///D:/AppsPath/apache-jena-fuseki-3.8.0/run/databases/rules.ttl> ] ;
    ja:baseModel <#g> ;
    .

<#g> rdf:type tdb:GraphTDB ;
    tdb:location "E:/data/tdb" ;
    tdb:unionDefaultGraph true ; 
    .

步骤2:rules.ttl

在规则之间添加一个逗号

[ruleComedian: (?p :hasActedIn ?m), (?m :hasGenre ?g), (?g :genreName '喜剧') 
-> (?p rdf:type :Comedian)]
[ruleInverse: (?p :hasActedIn ?m) -> (?m :hasActor ?p)]