Sparql 当我自定义JENA FUSEKI的规则时,表中没有可用的数据?

Sparql 当我自定义JENA FUSEKI的规则时,表中没有可用的数据?,sparql,rdf,jena,fuseki,jena-rules,Sparql,Rdf,Jena,Fuseki,Jena Rules,当我自定义JENA FUSEKI的规则时,表中没有可用的数据 ttl是rdf:type owl:Ontology 和规则。ttl是我的自定义规则 删除规则.ttl顶部的@前缀后,如下所示 [ruleComedian: (?p :hasActedIn ?m) (?m :hasGenre ?g) (?g :genreName '喜剧') -> (?p rdf:type :Comedian)] [ruleInverse: (?p :hasActedIn ?m) -> (?m :hasA

当我自定义JENA FUSEKI的规则时,表中没有可用的数据

  • ttl是rdf:type owl:Ontology
  • 规则。ttl
    是我的自定义规则
删除
规则.ttl
顶部的
@前缀后,如下所示

[ruleComedian: (?p :hasActedIn ?m) (?m :hasGenre ?g) (?g :genreName '喜剧') -> (?p rdf:type :Comedian)]
[ruleInverse: (?p :hasActedIn ?m) -> (?m :hasActor ?p)]
@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 ;
    .
更新1:这是
规则顶部的
@前缀

@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#> .
我不知道我是否描述得很清楚


对不起,我忘记粘贴我的查询代码了

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

它现在运行得很好

谢谢

步骤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 ; 
    .

就像一个健全的检查,数据不是空的吗
SELECT*{s?p?o}LIMIT 10
“删除rules.ttl顶部的@前缀后”-这是什么意思?您必须添加自定义前缀
,或者不添加?此外,您可以使用SPARQL查询检查第一个规则的前提,即
前缀:select*{p:hasActedIn?m.?m:HasGene?g.?g:genreName'喜剧' } 限制10
-这是空的吗?请仔细检查前缀声明-显然,您没有显示任何示例数据,因此,我们无法判断是否已经存在mismatch@AKSW是,
SELECT*{s?p?o}LIMIT 10
It successful!“显示10个entriesShow entriesSearch中的1到10个。”
@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 ; 
    .
[ruleComedian: (?p :hasActedIn ?m), (?m :hasGenre ?g), (?g :genreName '喜剧') 
-> (?p rdf:type :Comedian)]
[ruleInverse: (?p :hasActedIn ?m) -> (?m :hasActor ?p)]