Hi all,

We did some more tests and found that the lower-level Graph API of Apache Jena 
contains the GraphListener interface of which instances can be added to a 
GraphEventManager. We have found that these listeners *do* get triggered when 
inferred statements are added to an InfGraph.

Regards, Barry

-----Original Message-----
From: Nouwt, B. (Barry) <[email protected]> 
Sent: dinsdag 8 januari 2019 09:36
To: [email protected]
Subject: RE: ModelChangedListener not triggered when new inferred statements 
are added.

Hi asj6f and Dave, thanks for your answers. If I remember correctly, we used a 
FORWARD rule to test it and no events were generated, but we'll look into it 
again to be sure. A custom built-in function might work, thanks!

Regards, Barry

-----Original Message-----
From: Dave Reynolds <[email protected]> 
Sent: maandag 7 januari 2019 21:29
To: [email protected]
Subject: Re: ModelChangedListener not triggered when new inferred statements 
are added.

Actually it depends on the rules and configuration of the GenericRuleReasoner.

For rules executed in backward mode it's exactly as ajs6f says, there's no 
extra statements added to a model.

For rules executed in forward mode then the inferred triples are added to the 
deductions graph (which is separate from the base graph which holds the data). 
So I imagine that a listener on the deductions graph should work. Not tested it 
myself though - the rule system largely predates the current version of 
listeners.

However, note that even in forward mode the inferences are only trigged when 
you ask a query or call prepare(). They are not immediately triggered by just 
adding new base triples.

Dave

On 07/01/2019 18:36, ajs6f wrote:
> Dave Reynolds will be able to say more, but my understanding is that inferred 
> triples are _not_ added to the model in the sense in which we might use 
> Model::add to add a Statement. They are simply presented by the 
> implementation as the model is scanned, "injected" by the inference 
> machinery, so to speak.
> 
> As for your use case, perhaps you could use a rule to do this? Again, I don't 
> know a lot about this end of Jena, but perhaps you could write a custom 
> built-in function for the rules system [1] .
> 
> ajs6f
> 
> [1] 
> https://jena.apache.org/documentation/inference/index.html#builtins
> 
>> On Jan 7, 2019, at 10:32 AM, Nouwt, B. (Barry) <[email protected]> 
>> wrote:
>>
>> Hi everyone,
>>   
>> We would like Apache Jena to raise an event whenever a particular triple is 
>> inferred by the GenericRuleReasoner.
>>   
>> We tried to achieve this by registering our implementation of the 
>> ModelChangedListener interface to an InfModel, but our implementation does 
>> not get triggered when inferred statements are added by the reasoner.
>>   
>> Is there any (other) way to raise an event whenever an inferred statement is 
>> added to an InfModel?
>>   
>> Regards, Barry
>>   
>>   
>>   
>> B. (Barry) Nouwt
>> Medior Innovator Semantic Technology
>> Connected Business
>> T +31 (0)88 866 56 91
>> M +31 (0)64 977 53 56
>> E [email protected]
>> Location
>>
>>   
>>
>> This message may contain information that is not intended for you. If you 
>> are not the addressee or if this message was sent to you by mistake, you are 
>> requested to inform the sender and delete the message. TNO accepts no 
>> liability for the content of this e-mail, for the manner in which you use it 
>> and for damage of any kind resulting from the risks inherent to the 
>> electronic transmission of messages.
> 

Reply via email to