You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Dimov, Stefan" <st...@sap.com> on 2017/03/22 20:07:32 UTC

How to configure Fuseki to load my inference rules on start

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

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


I'm starting the server from a console with:

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


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.


Re: How to configure Fuseki to load my inference rules on start

Posted by "Dimov, Stefan" <st...@sap.com>.
Thanks, Dave!

S.

On 3/23/17, 2:14 AM, "Dave Reynolds" <da...@gmail.com> wrote:

    On 22/03/17 20:07, Dimov, Stefan wrote:
    
    > 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?
    
    The rule looks correct for making ao:isA a transitive property.
    
    [Aside: Be careful when using predicates called "isA". In the early days 
    of semantic networks people used an informal notion of "is a" before 
    they realized it conflates different concepts e.g. generalization 
    (rdfs:subClsssOf) v.s. instantiation (rdf:type).]
    
    Dave
    


Re: How to configure Fuseki to load my inference rules on start

Posted by Dave Reynolds <da...@gmail.com>.
On 22/03/17 20:07, Dimov, Stefan wrote:

> 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?

The rule looks correct for making ao:isA a transitive property.

[Aside: Be careful when using predicates called "isA". In the early days 
of semantic networks people used an informal notion of "is a" before 
they realized it conflates different concepts e.g. generalization 
(rdfs:subClsssOf) v.s. instantiation (rdf:type).]

Dave

Re: How to configure Fuseki to load my inference rules on start

Posted by "Dimov, Stefan" <st...@sap.com>.
Thanks, Soroka,

No, it doesn’t. If I remove –update, the server just starts in read-only mode, but the result is the same.

And I’m also sure that –update doesn’t override –file, because the config file is being read, even though the data and rules files are being ignored – if I put some erroneous symbols in new_config.ttl, I get an error and the server doesn’t start.

S. 


On 3/23/17, 12:57 PM, "A. Soroka" <aj...@virginia.edu> wrote:

    I may be mixing up issues here, but I suspect that --update may override --file=<config>. Can you quickly try again without the --update flag?
    
    ---
    A. Soroka
    The University of Virginia Library
    
    > On Mar 23, 2017, at 3:55 PM, Dimov, Stefan <st...@sap.com> wrote:
    > 
    > Thanks, Andy,
    > 
    > Now my config file 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:RDFDataset ;
    >                ja:defaultGraph <#infGraph> .
    > 
    > <#infGraph>  rdf:type ja:InfModel ;
    >             ja:reasoner [  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
    >                            ja:rulesFrom <file:Data/inference_rules.rules> ; ] .
    > 
    > <#data> rdf:type ja:MemoryModel ;
    >     ja:content [ja:externalContent <file:Data/graph.nt>] ;
    >     .
    > 
    > 
    > 
    > Unfortunately, it doesn’t work. Both files inference_rulesss.rules and graph.nt are being ignored. (I’ve put them into: <fuseki_home>/Data folder). I tried different formats for <file:Data/inference_rulesss.rules>, like <file://Data/inference_rulesss.rules> or <Data/inference_rulesss.rules>, but it didn’t work.
    > 
    > Also, you said that in the command line:
    > 
    >       ./fuseki-server --update --file=config_new.ttl /mainservice
    > 
    > I don’t not need the /mainservice, but when I try to start the service with:
    > 
    >       ./fuseki-server --update --file=config_new.ttl
    > 
    > I get:
    > 
    > 		No dataset path name given
    > 
    > and the server doesn’t start.
    > 
    > Regards,
    > Stefan
    > 
    > 
    > On 3/23/17, 1:43 AM, "Andy Seaborne" <an...@apache.org> wrote:
    > 
    > 
    >    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.
    >> 
    > 
    > 
    
    


Re: How to configure Fuseki to load my inference rules on start

Posted by "A. Soroka" <aj...@virginia.edu>.
I may be mixing up issues here, but I suspect that --update may override --file=<config>. Can you quickly try again without the --update flag?

---
A. Soroka
The University of Virginia Library

> On Mar 23, 2017, at 3:55 PM, Dimov, Stefan <st...@sap.com> wrote:
> 
> Thanks, Andy,
> 
> Now my config file 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:RDFDataset ;
>                ja:defaultGraph <#infGraph> .
> 
> <#infGraph>  rdf:type ja:InfModel ;
>             ja:reasoner [  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
>                            ja:rulesFrom <file:Data/inference_rules.rules> ; ] .
> 
> <#data> rdf:type ja:MemoryModel ;
>     ja:content [ja:externalContent <file:Data/graph.nt>] ;
>     .
> 
> 
> 
> Unfortunately, it doesn’t work. Both files inference_rulesss.rules and graph.nt are being ignored. (I’ve put them into: <fuseki_home>/Data folder). I tried different formats for <file:Data/inference_rulesss.rules>, like <file://Data/inference_rulesss.rules> or <Data/inference_rulesss.rules>, but it didn’t work.
> 
> Also, you said that in the command line:
> 
>       ./fuseki-server --update --file=config_new.ttl /mainservice
> 
> I don’t not need the /mainservice, but when I try to start the service with:
> 
>       ./fuseki-server --update --file=config_new.ttl
> 
> I get:
> 
> 		No dataset path name given
> 
> and the server doesn’t start.
> 
> Regards,
> Stefan
> 
> 
> On 3/23/17, 1:43 AM, "Andy Seaborne" <an...@apache.org> wrote:
> 
> 
>    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.
>> 
> 
> 


Re: How to configure Fuseki to load my inference rules on start

Posted by Andy Seaborne <an...@apache.org>.

On 23/03/17 19:55, Dimov, Stefan wrote:
> Thanks, Andy,
>
> Now my config file 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:RDFDataset ;
>                 ja:defaultGraph <#infGraph> .
>
> <#infGraph>  rdf:type ja:InfModel ;
>              ja:reasoner [  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
>                             ja:rulesFrom <file:Data/inference_rules.rules> ; ] .
>
> <#data> rdf:type ja:MemoryModel ;
>      ja:content [ja:externalContent <file:Data/graph.nt>] ;
>      .
>

I don't see a connection between <#infGraph> and <#data>.  Don't you 
need a ja:baseModel?

That said, it worked for me with a rule of just:

-------------
  -> (<http://example/s> <http://example/p> <http://example/o> ) .
-------------
>
>
> Unfortunately, it doesn\u2019t work. Both files inference_rulesss.rules and graph.nt are being ignored. (I\u2019ve put them into: <fuseki_home>/Data folder). I tried different formats for <file:Data/inference_rulesss.rules>, like <file://Data/inference_rulesss.rules> or <Data/inference_rulesss.rules>, but it didn\u2019t work.
>
> Also, you said that in the command line:
>
>        ./fuseki-server --update --file=config_new.ttl /mainservice
>
> I don\u2019t not need the /mainservice, but when I try to start the service with:
>
>        ./fuseki-server --update --file=config_new.ttl

--conf=config_new.ttl

--help says:

"""
  --file=FILE            Create an in-memory, non-persistent dataset for 
the server, initialised with the contents of the file
"""


>
> I get:
>
> 		No dataset path name given
>
> and the server doesn\u2019t start.

--update is not relevant - the configuration file takes precedence (the 
presence of "serviceUpdate" etc.

	Andy
>
> Regards,
> Stefan
>

Re: How to configure Fuseki to load my inference rules on start

Posted by "Dimov, Stefan" <st...@sap.com>.
Thanks, Andy,

Now my config file 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:RDFDataset ;
                ja:defaultGraph <#infGraph> .
 
<#infGraph>  rdf:type ja:InfModel ;
             ja:reasoner [  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
                            ja:rulesFrom <file:Data/inference_rules.rules> ; ] .

<#data> rdf:type ja:MemoryModel ;
     ja:content [ja:externalContent <file:Data/graph.nt>] ;
     .



Unfortunately, it doesn’t work. Both files inference_rulesss.rules and graph.nt are being ignored. (I’ve put them into: <fuseki_home>/Data folder). I tried different formats for <file:Data/inference_rulesss.rules>, like <file://Data/inference_rulesss.rules> or <Data/inference_rulesss.rules>, but it didn’t work.

Also, you said that in the command line:

       ./fuseki-server --update --file=config_new.ttl /mainservice
    
I don’t not need the /mainservice, but when I try to start the service with:

       ./fuseki-server --update --file=config_new.ttl
       
I get:

		No dataset path name given

and the server doesn’t start.

Regards,
Stefan


On 3/23/17, 1:43 AM, "Andy Seaborne" <an...@apache.org> wrote:

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


Re: How to configure Fuseki to load my inference rules on start

Posted by Andy Seaborne <an...@apache.org>.
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.
>