(Dave is not around at the moment so I'll try to answer some parts of
your question ...)
On 28/01/15 10:28, "Sébastien Boulet [intactile DESIGN]" wrote:
Hello,
I have two rules which could produce the same triple:
String rules = "[r1: (?a eg:p ?b) -> (?a, eg:q, ?b)]" +
"[r2: (?a eg:r ?b) -> (?a, eg:q, ?b)]";
i have configured a GenericRuleReasoner in FORWARD_RETE mode.
GenericRuleReasoner reasoner = new
GenericRuleReasoner(Rule.parseRules(rules));
reasoner.setMode(GenericRuleReasoner.FORWARD_RETE);
InfModel model = ModelFactory.createInfModel(reasoner,
ModelFactory.createDefaultModel());
When a triple satisfy the first rule and another triple satisfy the second rule:
Resource subject = model.createResource();
Property predicateP = model.getProperty("urn:x-hp:eg/p");
Literal literalA = model.createTypedLiteral("A");
Property predicateR = model.getProperty("urn:x-hp:eg/r");
model.add(subject, predicateP, literalA);
model.add(subject, predicateR, literalA);
only one triple is deduced:
An RDF graph is a set of triples.
A set only has one of each thing in it.
If you
add(triple)
add(triple)
you will see only one triple in the output. This is not to do with
inference, it is to do with an RDF graph being a set.
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:j.0="urn:x-hp:eg/" >
<rdf:Description rdf:nodeID="A0">
<j.0:r rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A</j.0:r>
<j.0:p rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A</j.0:p>
<j.0:q rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A</j.0:q>
</rdf:Description>
</rdf:RDF>
When i remove the fist triple:
model.remove(subject, predicateP, literalA);
the sole deduced triple is removed even if the second rule is still satisfied:
You ran the reasoner in forward model - it included all deductions at
the start and then does not run again until you ask it to.
To trigger it again:
InfModel.rebind()
"Cause the inference model to reconsult the underlying data to take into
account changes."
or run in backward mode.
Andy
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:j.0="urn:x-hp:eg/" >
<rdf:Description rdf:nodeID="A0">
<j.0:r rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A</j.0:r>
</rdf:Description>
</rdf:RDF>
is it the expected behavior ?
is there a workaround to deduce twice the same triple or at least to don’t
remove the sole deduction ?
Thanks
Sébastien BOULET
LEAD DÉVELOPPEUR
intactile DESIGN
Création d’interfaces + subtiles
04 67 52 88 61
09 50 12 05 66
20 rue du carré du roi
34000 MONTPELLIER
France
www.intactile.com <http://intactile.com/>
Les informations contenues dans cet email et ses documents attachés sont
confidentielles. Elles sont exclusivement adressées aux destinataires
explicitement désignés ci-dessus et ne peuvent être divulguées sans
consentement de son auteur. Si vous n'êtes pas le destinataire de cet email
vous ne devez pas employer, révéler, distribuer, copier, imprimer ou
transmettre le contenu de cet email et devez le détruire immédiatement.