I'm using GenericRuleReasoner to infer virtual fact in my ontology. GenericRuleReasoner takes inference rules as Datalog rule in input as explain in jena inference support. here is an example of a DatalogRule attached to a generic reasoner :
String rules = "[r1: (?e1 st:runningTask st:gic_eth0) -> (?e1 rdf:type st:dataFromEthernet2IP)]";
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
reasoner.setDerivationLogging(true);
InfModel inf = ModelFactory.createInfModel(reasoner, rawData);
When i tested this code on my data, it worked fine and infered 2000 virtual facts. However, when I changed the Datalog rule in order to create blank nodes like this
String rules = "[r1: (?e1 st:runningTask st:gic_eth0) -> (_:p rdf:type st:dataFromEthernet2IP)]";
I get only on virtual fact inferred.
Is there a problem with my blank node representation in datalog rule for GenericRuleReasoner ?
Is there a problem with my blank node representation in datalog rule for GenericRuleReasoner ?
Yes. You don't use blank nodes like this in Jena rules. The document that you linked to includes a grammar for rules, and there's nothing in it that would permit something like _:p
as a node. The syntax for nodes in Jena rules is:
node := uri-ref // e.g. http://foo.com/eg
or prefix:localname // e.g. rdf:type
or <uri-ref> // e.g. <myscheme:myuri>
or ?varname // variable
or 'a literal' // a plain string literal
or 'lex'^^typeURI // a typed literal, xsd:* type names support
If you want to create a new blank node, use the makeTemp(?x)
bulitin in the body of the rule to bind ?x
to a new blank node. E.g.,
[r1: (?e1 st:runningTask st:gic_eth0), makeTemp(?p)
->
(?p rdf:type st:dataFromEthernet2IP) ]