No data available in table, when I customize the rules of JENA FUSEKI?
movies.ttl
is the rdf:type owl:Ontology. rules.ttl
is my custom rule.After deleting the @prefix
at the top of rules.ttl
, as follows,
[ruleComedian: (?p :hasActedIn ?m) (?m :hasGenre ?g) (?g :genreName '喜剧') -> (?p rdf:type :Comedian)]
[ruleInverse: (?p :hasActedIn ?m) -> (?m :hasActor ?p)]
Update 1: It's the @prefix
at the top of rules.ttl
,
@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#> .
In addition,
I have added
fuseki_conf.ttl
in the path ofD:\AppsPath\apache-jena-fuseki-3.8.0\run\configuration\fuseki_conf.ttl
.
The fuseki_conf.ttl
as follows,
@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 ;
.
I don't know if I have described it clearly.
Sorry, I forgot to paste my query code.
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
The final SPARQL query result is No data available in table
.
Thanks.
Update 2: The rules are that I copied it from Internet( It is correct). However, since the JENA FUSEKI version has been upgraded, I need to modify the fuseki_conf.ttl
file.
I think the problem should be that my modified fuseki_conf.ttl
is wrong.
Update 3: The old fuseki_conf.ttl
( It is correct)
@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" ;
It works very well now.
Thanks.
Step 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 ;
.
Step 2:rules.ttl
Add a comma between the rules
[ruleComedian: (?p :hasActedIn ?m), (?m :hasGenre ?g), (?g :genreName '喜剧')
-> (?p rdf:type :Comedian)]
[ruleInverse: (?p :hasActedIn ?m) -> (?m :hasActor ?p)]