Problem in saving class instances to file

2016-12-01 Thread kumar rohit
Hi
I want to create student instances of my Student class and enter his
details. Then at the end I writes model to the file.

 OntClass std = model.getOntClass(ns + "Student");
  Individual mystd = std.createIndividual(ns + stdname);

In the file when I enter name of a student, i-e Bob, it saves to the file
along other information like department, address etc.
Next time, when I enter another student name, i-e Alice, it replaces
previous instances of students and currently only one student is saved to
file.

I want record of all students so need all student instances. I used for
file writing.

try (FileOutputStream write = new FileOutputStream("D://students.owl")) {
   model.write(write, "RDF/XML");


Re: Correct syntax of rules

2016-12-01 Thread Martynas Jusevičius
Why would you think that? Does the documentation say that?
https://jena.apache.org/documentation/inference/#rules

On Thu, Dec 1, 2016 at 1:45 PM, neha gupta  wrote:
> Thanks Dave, its really new knowledge for me as I thought ^ is used as
> AND(conjunction).
>
> On Thu, Dec 1, 2016 at 2:03 AM, Dave Reynolds 
> wrote:
>
>> On 30/11/16 17:55, neha gupta wrote:
>>
>>> (1) greaterThan(?score1,?score2)^(?score1, ?score3)
>>>
>>>  (2) greaterThan(?score1,?score2)^ greaterThan(?score1, ?score3)
>>>
>>>  In Jena rules, the ist statement is correct or the second?
>>>
>>
>> Neither, conjunction of terms in Jena rules is just "," so
>>
>>  ... greaterThan(?score1,?score2), greaterThan(?score1, ?score3) ...
>>
>> Dave
>>
>>
>>


Re: Super classes/Sub classes in Jena rules

2016-12-01 Thread tina sani
 Hello Lorenz, Dave, I have used the above method and suddenly I get this
exception:

 WARN [AWT-EventQueue-0] (Rule.java:947) - Rule references unimplemented
functor: ^

Where it comes from?

On Sun, Nov 27, 2016 at 2:59 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> > Hi Dave,
> >
> > So in that case we dont need to add non-inference model to the generic
> > reasoner because after all, our whole data is in the model.
> Yes, it is simply nested:
> Raw model A is "contained" in the inferred RDFS model B.
> B is "contained" in your user-defined rule model C.
> Thus, A is "contained" in C.
> >
> >
> > On Sat, Nov 26, 2016 at 11:55 AM, Dave Reynolds <
> dave.e.reyno...@gmail.com>
> > wrote:
> >
> >> On 25/11/16 13:54, tina sani wrote:
> >>
> >>> I have something like this after my Jena forward chain rules and SPARQL
> >>> query:
> >>>
> >>>  Reasoner reasoner1 = new GenericRuleReasoner(Rule.parseRules(rule));
> >>> InfModel inf = ModelFactory.createInfModel(reasoner1, model);
> >>>
> >>> Reasoner reasoner2 = ReasonerRegistry.getRDFSReasoner();
> >>>
> >>> InfModel inf2 = ModelFactory.createRDFSModel(model);
> >>>
> >> If you want your rules to see the results of the RDFS closure then you
> >> need something more like:
> >>
> >> InfModel inf = ModelFactory.createRDFSModel(model);
> >> Reasoner reasoner1 = new GenericRuleReasoner(Rule.
> parseRules(rule));
> >> InfModel inf2 = ModelFactory.createInfModel(reasoner1, inf);
> >>
> >> Dave
> >>
> >>
> >> On Fri, Nov 25, 2016 at 4:46 PM, tina sani 
> wrote:
> >>> So all I should so is to create rdfs model:
>  InfModel inf2 = ModelFactory.createRDFSModel();
> 
>  What would be the arguments of the ModelFactory.createRDFSModel(). I
>  have two models here, one the simple non inference model and other the
>  inference model : InfModel inf = ModelFactory.createInfModel(
> reasoner,
>  model);
> 
> 
> 
> 
>  On Fri, Nov 25, 2016 at 3:59 PM, Lorenz B.   leipzig.de> wrote:
> 
> 
> > Yes I use GenericRuleReasoner, so using the following rules along
> with
> > my
> >
> >> own rules will solve the problem?
> >>
> >> ?x rdfs:subClassOf emp:ContractEmployee--> ?x rdfs:subClassOf
> >>
> > emp:Employee
> >
> >> ?x rdfs:subClassOf emp:PermanantEmployee--> ?x rdfs:subClassOf
> >>
> > emp:Employee
> > That might be incomplete as rdfs:subClassOf is transitive. Simply use
> > the RDFS reasoning.
> >
> >> On Thu, Nov 24, 2016 at 11:39 AM, Lorenz B. <
> >> buehm...@informatik.uni-leipzig.de> wrote:
> >>
> >>  If I pass OntModelSpec.OWL_MEM_MICRO_RULE_INF” to the OntModel,
> will
> >>> it do
> >>>
>  the RDFS reasoning?
> 
> >>> See [1] in general and in particular [2] which shows how to setup
> an
> >>> RDFS reasoner
> >>>
> >>> InfModel inf = ModelFactory.createRDFSModel(rdfsExample);
> >>>
> >>> or
> >>>
> >>> Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
> >>> InfModel inf = ModelFactory.createInfModel(reasoner, rdfsExample);
> >>>
> >>> [1] https://jena.apache.org/documentation/inference/ [2]
> >>> https://jena.apache.org/documentation/inference/#generalExamples
> >>>
>  b) adding the particular rules to your set of rules
>   I have already created the rules, mentioned in my first email.
> You
> 
> >>> means
> >> rules other than that?
> >>> I don't know how you setup your rules, but if you use the
> >>> GenericRuleReasoner it does only apply your rules and you would
> have
> >>> to
> >>> add the rules that do the rdfs:subClass/rdf:type inference.
> >>>
>  On Wed, Nov 23, 2016 at 11:50 AM, Lorenz B. <
>  buehm...@informatik.uni-leipzig.de> wrote:
> 
>  Dave meant that you need an additional layer of reasoning like
> RDFS
>  or
> >> even less to get the inferences that you describe.
> > This can be done by
> >
> > a) nesting two InfModels one that works on your specific rules
> and
> >
>  one
> >> that uses some kind of RDFS or
> > b) adding the particular rules to your set of rules
> >
> > Ok sorry Dave, actually I did not completely understand your
> answer.
> >> "You could have an inference model with the appropriate
> >>
> > configuration
> >> to
>  deduce membership of employee"
> >> Yes I have the inference model:
> >>  Reasoner reasoner = new GenericRuleReasoner(Rule.parse
> >>
> > Rules(rule));
> >> InfModel infer = ModelFactory.createInfModel(reasoner,
> > model);
> >> Query query = QueryFactory.create(queryString);
> >>
> >>  QueryExecution qe = QueryExecutionFactory.create(query,
> 

Re: Correct syntax of rules

2016-12-01 Thread neha gupta
Thanks Dave, its really new knowledge for me as I thought ^ is used as
AND(conjunction).

On Thu, Dec 1, 2016 at 2:03 AM, Dave Reynolds 
wrote:

> On 30/11/16 17:55, neha gupta wrote:
>
>> (1) greaterThan(?score1,?score2)^(?score1, ?score3)
>>
>>  (2) greaterThan(?score1,?score2)^ greaterThan(?score1, ?score3)
>>
>>  In Jena rules, the ist statement is correct or the second?
>>
>
> Neither, conjunction of terms in Jena rules is just "," so
>
>  ... greaterThan(?score1,?score2), greaterThan(?score1, ?score3) ...
>
> Dave
>
>
>