On 22/03/17 20:07, Dimov, Stefan wrote:
Hi all,

I'm new to Apache Jena and Fuseki. I've installed Apache Jena Fuseki as a 
standalone server and I'm trying to define a very simple inference rule and 
seemingly, I'm not configuring it correctly. My configuration file 
config_new.ttl looks like this:


@prefix :        <#> .
@prefix fuseki:  <http://jena.apache.org/fuseki#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix ao:      <http://ao.com> .

[] rdf:type fuseki:Server ;
   fuseki:services (
       <#mainservice>
   ) .

<#mainservice> rdf:type fuseki:Service ;
    fuseki:name                       "mainservice" ;
    fuseki:serviceQuery               "sparql"      ;
    fuseki:serviceQuery               "query"       ;
    fuseki:serviceUpdate              "update"      ;
    fuseki:serviceUpload              "upload"      ;
    fuseki:serviceReadWriteGraphStore "data"        ;
    fuseki:serviceReadGraphStore      "get"         ;
    fuseki:dataset                    <#ao>         ;
   .

### In-memory, initially empty.
## This database set-up allows OWL inference.
<#ao> rdf:type ja:MemoryModel ;
                ja:defaultGraph <#infGraph> .

As already mentioned on StackOverflow, this is wrong. You must put graphs in a dataset.

<#ao> rdf:type ja:RDFDataset ;


<#infGraph>  rdf:type ja:InfModel ;
             ja:reasoner [ ja:rulesFrom <file:inference_rules.rules> ; ] .

Try adding a reasoner:

ja:reasoner
[ ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
          ja:rulesFrom <inference_rules.rules>
        ] ;

and make sure inference_rules.rules is accessible in the right location to the server.

and put in a base graph:

<#infGraph> rdf:type ja:InfModel ;
  ja:baseModel <#data> ;
  ja:reasoner
      [ ja:reasonerURL
              <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
        ja:rulesFrom <...>
      ] ;
  .

<#data> rdf:type ja:MemoryModel ;
    ja:content [ja:externalContent <initial_data.ttl>] ;
    .





I'm starting the server from a console with:

./fuseki-server --update --file=config_new.ttl /mainservice

You do not need the /mainservice -- it is in the config file at fuseki:name

(examples not checked - hopefully someone can confirm/correct them)

    Andy



It's starting and I am able to upload some data and query it successfully from 
the web-page, but seemingly it doesn't read the file inference_rules.rules. 
Even if the file name is wrong or the file doesn't exist or the contents of the 
file is incorrect, I don't get any errors and the rule is not working.
What am I missing?
There's a second question here. Apparently, I'm not there yet, but let me put 
here the contents of inference_rules.rules. I'm trying to define a simple 
transitive rule - if (A is a B) and (B is a C), then A is a C:


@prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
@prefix ex: http://example.com/
@prefix xs: http://www.w3.org/2001/XMLSchema#
@prefix ao: http://ao.com/

[isA:
(?a ao:isA ?b)
(?b ao:isA ?c)
                 ->
                 (?a ao:isA ?c)
         ]


Did I define it correctly?

Regards,
S.

Reply via email to