No, your rules are in Jena rules format. 
The problem is that your rules are in Jena format but in the code, you are 
calling the OWL reasoner.
Solution:
Call the GenericReasoner instead of the OWL reasoner. Like this:
String rules = [AddingJim: -> 
(sf:Jim rdf:type sf:Person)
(sf:Jim sf:hasMembership sf:True)
]
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));

 
Zahir KALI
Master 2 Architecture et ingénierie de logiciel et de web
Université Montpellier 2
Tel: 06 73 81 06 08
Github: https://github.com/ZahirKali?tab=repositories


Le Vendredi 7 novembre 2014 12h42, "Iturraspe Barturen, Urtza" 
<[email protected]> a écrit :
 


First of all, thanks for your response...


My rule follows this format:


https://wiki.csc.calpoly.edu/OntologyTutorial/wiki/AddingRulesToOntologiesWithJena

[DescriptionOrNameOfRule:
(condition to be met)
(another condition)
->
(fact to assert)
(another fact to assert)
]


Example:
[AddingJim: 
-> 
(sf:Jim rdf:type sf:Person)
(sf:Jim sf:hasMembership sf:True)
]

In my case I add a type of Continent ..

[AddingContinent:
->
(places:XXX rdf:type places:Continent)
]

I think so that rule is in OWL format, isn't it?

Best regards,


OPTIMA - Optimization Modelling & Analytics Area

ICT - European Software Institute Division 

TECNALIA
Parque Tecnológico de Bizkaia, Edificio 202
E-48170 Zamudio (Spain)
mov.: 664 00 21 51
tel.: 902 760 002  /  946 430 850 (International calls) 
[email protected] 
www.tecnalia.com 


-----Mensaje original-----
De: Zahir Kali [mailto:[email protected]] 
Enviado el: viernes, 07 de noviembre de 2014 12:36
Para: [email protected]
Asunto: Re: Jena Rules and OSGI

Your rules are in OWL format?
As i see, you are extending an OWL reasoner but you want use Jena rules format.

Zahir KALI
Master 2 Architecture et ingénierie de logiciel et de web Université 
Montpellier 2
Tel: 06 73 81 06 08
Github: https://github.com/ZahirKali?tab=repositories


Le Vendredi 7 novembre 2014 12h14, "Iturraspe Barturen, Urtza" 
<[email protected]> a écrit :



Good morning,

I am working with Jena SDB and OSGI, developing with Eclipse and Bnd Tools 
plugin.

I want to execute a Jena rule and include infModel to JenaSDB Model, but It 
doesn't work in a REST service using OSGI.

I have tested the code and it's works well if I don't use this in a OSGI bundle 
...

I've create OSGI bundle for this versions of jars:

com.mysql.jdbc-5.1.22.jar
slf4j.log4j12-1.6.4.jar
xml-apis-1.4.1.jar
xercesImpl-2.10.0.jar
com.ibm.icu-54.1.1.jar
com.hp.hpl.jena.iri-0.8.0.jar
com.hp.hpl.jena.jena-2.6.4.jar
com.hp.hpl.jena.arq-2.8.7.jar
org.apache.jena.jena-iri-0.9.6.jar
com.hp.hpl.jena.sdb-1.3.4.jar
org.apache.jena.jena-core-2.7.4.jar


Any help, idea ?

The jena rule is very simple:

@prefix places: http://purl.org/ontology/places# @prefix rdfs: 
<http://www.w3.org/2000/01/rdf-schema#>.
@prefix owl2: <http://www.w3.org/2006/12/owl2#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
[AddingContinent: ->(places:XXX rdf:type places:Continent)]


I have this code:

  Model modelSDB = null;
  InfModel owlInfModel = null;
  InfModel rulesInfModel = null;

modelSDB = jenaSDBConector.loadModelSDB(databaseName);

  File file = new File(System.getProperty("java.io.tmpdir", null),"jena.rules");
    try{
    if (!file.exists()) {
      file.createNewFile();
    }
    }catch(Exception e){
      System.out.println(e.getMessage());
    }
    // get the content in bytes
    byte[] contentInBytes = jenaRule.getBytes();
    FileOutputStream  fop = new FileOutputStream(file);
    fop.write(contentInBytes);
    fop.flush();
    fop.close();

    Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
    owlInfModel = ModelFactory.createInfModel(reasoner, modelSDB);


    Resource conf = modelSDB.createResource();
    conf.addProperty(ReasonerVocabulary.PROPruleMode, "forwardRETE");
    conf.addProperty(ReasonerVocabulary.PROPruleSet, "/tmp/" + "jena.rules");

     reasoner = GenericRuleReasonerFactory.theInstance().create(conf);
    rulesInfModel = ModelFactory.createInfModel(reasoner, modelSDB);
    rulesInfModel.prepare();



    Model deductionModel = rulesInfModel.getDeductionsModel();   -> DEDUCTION 
MODEL IS EMPTY !!!!!!???????

    StmtIterator i = deductionModel.listStatements();
    while (i.hasNext()) {
        System.out.println(" - " + i.nextStatement() + "\n");
    }


    modelSDB.add(rulesInfModel);
    modelSDB.commit();
    bResult=true;



Thanks in advance

Urtza Iturraspe

OPTIMA - Optimization Modelling & Analytics Area

ICT - European Software Institute Division

TECNALIA
Parque Tecnológico de Bizkaia, Edificio 202
E-48170 Zamudio (Spain)
mov.: 664 00 21 51
tel.: 902 760 002  /  946 430 850 (International calls) 
[email protected]<mailto:[email protected]>
www.tecnalia.com<http://www.tecnalia.com/>

Reply via email to