Hi Pierre,

You've two options for combining a GRR rule set and RDFS inference either combine the rules into a single rule set and use a GRR configuration or, as you say, layer the GRR reasoner over the top of an RDFS reasoner.

1. To combine the rules then in your GRR rule set use the directive:

    @include <RDFS>.

to include the rules for RDFS inference before your own rules. There are some restrictions here though. Firstly, the default RDFS rules which are included by this method need the transitive reasoner enabled. Programmatically that's easy:

   reasoner.setTransitiveClosureCaching(true);

However, I'm not sure if the assembler notation supports that. I'm not really familiar with the assembler machinery but a quick glance through the documentation and schema didn't turn up any obvious way to set this.

If there really is no way to set this flag in assemblers, and if you are restricted to using assemblers, then a workaround (other than option 2, below) would be to use an RDFS rule set which doesn't need the transitive reasoner. Jena includes such a rule set:

https://github.com/apache/jena/blob/master/jena-core/src/main/resources/etc/rdfs-fb.rules

You could copy those somewhere visible to your application and @include them from there.

The other limitation of the single ruleset approach is that, because the RDFS rules using a mix of forward and backward chaning, the rules you add on top all[*] need to be written as backward chaining rules. Otherwise they won't "see" the results of the RDFS backward chaining rules.

2. The alternative is, as you say, to configure an RDFS reasoner, then configure a GRR instances whose base model is your RDFS reasoner. You wouldn't then need a union as well - all the triples visible in the RDFS InfGraph would be visible through the GRR InfGraph.

Dave

[*] Well, at least those that might be affected by the results of RDFS inference.

On 19/07/2019 22:36, Pierre Grenon wrote:
apologies for piecemeal post -- didn't copy the whole file at first, so the 
RDFS reasoner, in particular, wasn't there.

I'm wondering if I need to have an inf model with the GRR reasoner with an RDFS 
reasoner submodel and also the reverse and then union these... sounds a bit 
weird.

With many thanks,
Pierre

*Rest of config file*

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION.
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN.

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014).
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS,
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/.

HORIZON ASSET LLP IS AUTHORISED AND REGULATED
BY THE FINANCIAL CONDUCT AUTHORITY.


<#theModel_RDFS> a ja:InfModel ;
     ja:baseModel <#theGraph> ;
        ja:reasoner [
            ja:reasonerURL <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner>
                ] ;
.

<#theGraph> rdf:type tdb2:GraphTDB ;
    tdb2:dataset :theTDB2Dataset .
                
:theTDB2Dataset
         a              tdb2:DatasetTDB2 ;
         tdb2:location  
"C:\\dev\\apache-jena-fuseki-3.10.0\\run/databases/Conference1" ;
                tdb2:unionDefaultGraph true.

-----Original Message-----
From: Pierre Grenon
Sent: 19 July 2019 17:48
To: 'users@jena.apache.org'
Subject: Combining inferences from GRR and RDFS or OWL reasoner

Hello,

(I apologise for I am not sure if this has been addressed before and I have
not found the right thread or documentation.)

The configuration file below seems to allow reasoning with either a GRR or
an out of the box reasoner on the same dataset.

However, I don't think it allows combining inferences from both reasoners at
the same time. I am not sure how to achieve this through configuration.

(Happy to provide an example of data and rule for the GRR. I've noticed this
when adding a rule to classify undeclared individuals, i.e., individuals
appearing in the subject position of a triple. The rule to the effect that if
they do, they are instances of a class A. It is possible to derive the
instantiation. However, it is not possible to combine it with type inheritance
from a reasoner. If class A is a subclass of class B, there is no inference to 
the
effect that the individual is also an instance of class B.)

With many thanks and kind regards,
Pierre




-----


@prefix :      <http://base/#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix tdb2:  <http://jena.apache.org/2016/tdb#> .
@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#> .

:theService a                   fuseki:Service ;
         rdfs:label                    "Service with update and query to test 
minimal
dataset with inference using an instance of generic rule reasoner and
RDFSExptRuleReasoner" ;
         fuseki:dataset                :theDataset ;
                #:tdb_dataset_readwrite ;
         fuseki:name                   "Conference2" ;
         fuseki:serviceQuery           "query" , "sparql" ;
         fuseki:serviceReadGraphStore  "get" ;
         fuseki:serviceReadWriteGraphStore
                 "data" ;
         fuseki:serviceUpdate          "update" ;
         fuseki:serviceUpload          "upload" .

:theDataset a ja:RDFDataset ;
     ja:defaultGraph <#theUnionModel>
        .

<#theUnionModel> a ja:UnionModel ;
                ja:rootModel <#theRootModel> ;
                ja:subModel <#theModel_GRR> , <#theModel_RDFS> .

<#theRootModel> a ja:Model ;
     ja:baseModel <#theGraph> ;
.


<#theModel_GRR> a ja:InfModel ;
     ja:baseModel <#theGraph> ;
        ja:reasoner [
                ja:reasonerURL
<http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
                ja:rulesFrom <file:///C:/dev/apache-jena-fuseki-
3.10.0/data/conference/conference1.rules>
        ] ;
.

Reply via email to