0

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

  • movies.ttl is the rdf:type owl:Ontology.
  • And 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 of D:\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" ;
Francis QING
  • 63
  • 1
  • 4
  • just as a sanity check, the data isn't empty at all? `SELECT * { ?s ?p ?o } LIMIT 10` – UninformedUser Sep 06 '18 at 13:50
  • *"After deleting the @prefix at the top of rules.ttl"* - what does this mean? you have to add your custom prefix `:`, or not? – UninformedUser Sep 06 '18 at 13:52
  • In addition, you can check the premise of the first rule with a SPARQL query, i.e. `prefix : select * { ?p :hasActedIn ?m. ?m :hasGenre ?g. ?g :genreName '喜剧' } limit 10` - is this empty? – UninformedUser Sep 06 '18 at 13:54
  • And please, double check the prefix declaration - clearly, you didn't show any sample data, thus, we can't judge whether there is already a mismatch – UninformedUser Sep 06 '18 at 13:55
  • @AKSW Yes, `SELECT * { ?s ?p ?o } LIMIT 10` It is successful! "Showing 1 to 10 of 10 entriesShow entriesSearch." – Francis QING Sep 06 '18 at 14:40
  • And what about `prefix : select * { ?p :hasActedIn ?m. ?m :hasGenre ?g. ?g :genreName '喜剧' } limit 10` ? this is the premise of your first rule – UninformedUser Sep 07 '18 at 06:38
  • Thanks! @AKSW - After your reminder, I found the problem - `my fuseki_conf.ttl is bad`. As you can see, in the replay(downstairs). - Now it's working! but, I don't why! thanks again. – Francis QING Sep 07 '18 at 07:29
  • Well, at least the path to your custom rules file is different, or not? – UninformedUser Sep 07 '18 at 08:03
  • Both the path and the rule are bad. @AKSW – Francis QING Sep 07 '18 at 10:10

1 Answers1

0

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)]
Francis QING
  • 63
  • 1
  • 4