I have a Jena Model filled with statements and use a GenericRuleReasoner
with custom rule strings as follow (Example directly taken from Jena tutorial page)
String rules = "[rule1: (?a eg:p ?b) (?b eg:p ?c) -> (?a eg:p ?c)]";
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
reasoner.setDerivationLogging(true);
InfModel inf = ModelFactory.createInfModel(reasoner, model);
From my understanding of Jena reasoner, new inference model inf
would contain statements from model
as well as newly inferred statements generated by the rules. Are instances of statements in both inf
and model
shared or different? If different, wouldn't this waste memory too much?
An issue that I'm having is reusing inferred statements into the model
. Looping through inf
model to find newly inferred statements and adding them to model
seems to be a naive approach. Is there any other wiser method?
Lastly, I am wondering what would be the best approach to remove outdated statement from model
. What I mean by an outdated statement is probably best explained by an example.
Say there is a statement (Speaker hasSoundLevel 50) in the model
. Later, when a new statement such as (Speaker hasSoundLevel 80) is inserted, it should invalidate(i.e. delete) (Speaker hasSoundLevel 50) from the model
. Could this be achieved by using a rule? What if a statement needs to be outdated after certain amount of time since its insertion? Any suggestions on how to achieve this would be appreciated.
Thanks,