Ok. Thank you Dave.

Sent from my iPhone

On 12/12/2012, at 8:30 PM, Dave Reynolds <[email protected]> wrote:

> Hi,
> 
> The documentation on the rule system is:
> http://jena.apache.org/documentation/inference/index.html#rules
> 
> Though I imagine if you've seen that already.
> 
> That should be enough to see how to have multiple rules in one rule set and 
> how to write forward rules instead of backward rules.
> 
> As to passing models around I'm not sure what documentation would be helpful. 
> Your "applyRule" function returns an InfModel but takes a String argument. 
> You could instead have it take a Model as an argument and have your "infer*" 
> functions consume and generate Models.
> 
> Dave
> 
> On 12/12/12 08:48, Oana Ureche wrote:
>> Hi Dave,
>> 
>> Well.. I don't know the library well.
>> Thank you for the input. Is there any documentation or tutorials about what 
>> you're recommending?
>> 
>> Thank you,
>> Oana.
>> 
>> Sent from my iPhone
>> 
>> On 12/12/2012, at 7:31 PM, Dave Reynolds <[email protected]> wrote:
>> 
>>> On 12/12/12 04:07, Oana Ureche wrote:
>>>> Hi all,
>>>> 
>>>> There is a shortcoming in Jena. Mainly the fact that it cannot handle 
>>>> complex rules.. i.e. throwing the following exception
>>>> 
>>>> Exception in thread "main" 
>>>> com.hp.hpl.jena.reasoner.rulesys.impl.LPRuleSyntaxException: Syntax error 
>>>> in backward rule: rule1
>>>> Rule too complex for current implementation
>>>> Rule clauses are limited to 15 permanent variables
>>>> 
>>>> So I have decided to split the complex rule into smaller rules. Then apply 
>>>> a small rule to a dataset, which results into a bigger dataset, then apply 
>>>> the next small rule to the bigger dataset and so on and so forth.. Code 
>>>> looks like the following:
>>> 
>>> Some suggestions here ...
>>> 
>>> Firstly, if you can split your big rule into smaller rules then why not do 
>>> so within one rule set? I don't follow the need to have separate rule sets.
>>> 
>>> Secondly, since your are running the inference to completion then forward 
>>> rules would be both higher performance and can handle more complex rules 
>>> then backward rules.
>>> 
>>> Thirdly if you are going to split your rules into different rule sets then 
>>> just pass the models around. I don't understand why you are serializing the 
>>> models to strings and then deserializing them. Seems unnecessary.
>>> 
>>> Dave
>>> 
>>>> 
>>>>               private static InfModel applyRule(String dataset, String 
>>>> filepath) {
>>>> 
>>>> InputStream stream = new ByteArrayInputStream(dataset.getBytes("UTF-8"));
>>>> Model instances = ModelFactory.createDefaultModel();
>>>> instances.read(stream, null);
>>>> Reasoner reasoner = new GenericRuleReasoner(Rule.rulesFromURL(filepath));
>>>> reasoner.setDerivationLogging(true);
>>>> return ModelFactory.createInfModel(reasoner, instances);
>>>> }
>>>> private static String inferConnName(String dataset) {
>>>> InfModel inf = applyRule(dataset, "file:rules/conn_name.txt");
>>>> ByteArrayOutputStream out = new ByteArrayOutputStream();
>>>> inf.write(out, "RDF/XML");
>>>> return out.toString();
>>>> }
>>>> private static String inferStatementName(String dataset) {
>>>> InfModel inf = applyRule(dataset, "file:rules/statement_name.txt");
>>>> ByteArrayOutputStream out = new ByteArrayOutputStream();
>>>> inf.write(out, "RDF/XML");
>>>> return out.toString();
>>>> }
>>>> private static void getVuln(String dataset) {
>>>> String conn_name_dataset = inferConnName(dataset);
>>>> String statement_name_dataset = inferStatementName(conn_name_dataset);
>>>> InfModel inf = applyRule(statement_name_dataset, "file:rules/param.txt");
>>>>         //print out the statements in the model
>>>> StmtIterator iter = inf.listStatements();
>>>> while (iter.hasNext()) {
>>>>     Statement stmt      = iter.nextStatement();  // get next statement
>>>>                 ............................
>>>> 
>>>>          }
>>>> 
>>>> 
>>>> I was wondering if there is a better way to do this?
>>>> 
>>>> Thank you,
>>>> 
>>>> Oana.
> 

Reply via email to