Jenabean and Jena rules

11 views
Skip to first unread message

Anna Lu

unread,
Jul 15, 2010, 5:00:48 AM7/15/10
to jenabe...@googlegroups.com
I initiated the model with some data, then applied Jena rule on it but the rule doesn't work. Here is what I did:

    @Autowired
    private Model sourceModel;

    runInference() {

        initiate();

        Resource configuration = sourceModel.createResource();
        configuration.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid");
        configuration.addProperty(ReasonerVocabulary.PROPruleSet,".../test.rule");

        Reasoner rea = GenericRuleReasonerFactory.theInstance().create(configuration);

        InfModel infModel = ModelFactory.createInfModel(rea, sourceModel);
   
        infModel.prepare();

        Person person = new Person().load("person1");

        System.out.println("death date:" + person.getDeathDate().toString());
        System.out.println("birth date:" + person.getBirthDate().toString());
   }

   initiate () {
   
        Person person = new Person("person1", "Dudley Moore"); //new Person(id, name)

       Calendar deathCal = Calendar.getInstance();
       deathCal.set(Calendar.YEAR, 2002);
       deathCal.set(Calendar.MONTH, 2);
       deathCal.set(Calendar.DATE, 27);
       person.setDeathDate(deathCal.getTime());

       person.save();
   }

Jena rule:
(?person ont:DeathDate ?deathdate)
->
 (?person ont:BirthDate ?deathdate)


The result is:
print out the death date but the birth date is null.

Is there something I did wrong with Jenabean or with Jena inference?

Anna Lu

unread,
Jul 15, 2010, 5:27:21 AM7/15/10
to jenabe...@googlegroups.com
Hi,

I found solution. It works after merge infModel with sourceModel.
But I don't know why....
Reply all
Reply to author
Forward
0 new messages