Re: [topbraid-users] [SPIN API] Loading SPIN constraints dynamically in to an ontology

2010-10-08 Thread Rodolfo Rieckhof
Hello everyone,
thanks a lot  for your support ti finally worked.

Best regards
Rodolfo


2010/10/8 Holger Knublauch 

> Hi Rudolfo,
>
> yes I believe Scott has answered your question. Why don't you edit the file
> with TBC Free Edition to edit the query as spin:constraint for the class
> where it belongs to, using ?this to refer to the instances.
>
> Otherwise, you need to add a corresponding spin:constraint triple to the
> model programmatically.
>
> The CONSTRUCT also doesn't look like a constraint, but rather a rule. Your
> constraint needs to generate instances of spin:Constraint, or be an ASK
> query returning false.
>
> Good luck
> Holger
>
>
> On Oct 7, 2010, at 7:46 PM, Rodolfo Rieckhof wrote:
>
> Hello Holger,
> thanks for your offer here the eclipse project. I think the problem is,
> that i don´t really bind the constraint to the ontology. In the Zip there
> are 2 classes: SPINExample here is where i tried to use spin. The other
> class is only a test, to look if  the query works outside spin. You must
> also include:
> Jena 2.6.3, ARQ 2.8.5 and Spin . Thanks a lot for your help.
>
> Best Regards,
> Rodolfo
>
>
>
> 2010/10/7 Holger Knublauch 
>
> Hi Rudolfo,
>>
>> I am not sure where the problem is in your example. I think I need more
>> information - feel free to send me your specific example (off-list). I
>> notice that you are creating the CONSTRUCT query but it is unclear whether
>> this constraint is also attached to the model somehow.
>>
>> Holger
>>
>>
>> On Oct 7, 2010, at 5:00 AM, Rodolfo Rieckhof wrote:
>>
>> Hello Holger,
>> thanks for your quick response. I have downloaded the new API and it works
>> just fine. But i have another question.
>> How can  i insert a SPIN constraint dynamically in my ontology ? I have
>> tried the following:
>> I create a constraint, just like in the examples with:
>>
>> ...
>> String query = prefixes +
>> "CONSTRUCT { _:b0 bad:deviceIngressProtection ?value;" +
>> " rdfs:label 'the value should be between 20 an 30'} " +
>> "WHERE { ?dev rdf:type bad:Device ; bad:deviceIngressProtection ?value ."
>> +
>> " FILTER ( ?value < 20 || ?value > 30) " +
>> "}";
>>
>> Query arqQuery = ARQFactory.get().createQuery(model, query);
>> ARQ2SPIN arq2SPIN = new ARQ2SPIN(model);
>> Construct spinQuery = (Construct) arq2SPIN.createQuery(arqQuery, null);
>>
>> //then i load my Onotology
>>
>> File root = new File("ontologies");
>> String  dataURL = new File(root.getAbsolutePath() +
>> "/Thermokon_Easysens_Funkschalter_BJ_V1.owl").toURI().toString();
>> Reasoner reasoner = PelletReasonerFactory.theInstance().create();
>>
>>  // create an empty model
>>OntModel ontModel = ModelFactory.createOntologyModel(
>> PelletReasonerFactory.THE_SPEC );
>>ontModel.read( dataURL );
>>
>> //add the   model with the Constraint
>> ontModel.addl(model);
>> SPINModuleRegistry.get().registerAll(ontModel);
>>
>> // let SPIN do its work
>> List cvs = SPINConstraints.check(ontModel, null);
>> System.out.println("Constraint violations:" + cvs.size());
>> for(ConstraintViolation cv : cvs) {
>> System.out.println(" - at " + SPINLabels.get().getLabel(cv.getRoot()) + ":
>> " + cv.getRoot());
>> }
>>
>>
>> the Problem is that i don´t get any constrains violation  (cvs = 0).
>> Although when i run the query with ARQ I get 1. Could you tell me please
>> wich is the wright way to do this ? . Is it a problem, that the is Ontology
>> in rdf ?
>>
>> Regards,
>> Rodolfo
>>
>>
>>
>>
>> 2010/10/6 Holger Knublauch :
>> > Hi Rodolfo,
>> >
>> > thanks a lot for this bug report. It was indeed a (simple) recursive
>> loop. Since this was a small but rather critical bug, I have just updated
>> the SPIN API that is on the web with a fix. The file has still the same
>> version number etc, but the infinite loop should be gone now. I plan to do a
>> proper release with a couple of new features in a few weeks after it went
>> through QA.
>> >
>> > Thanks again
>> > Holger
>> >
>> >
>> > On Oct 6, 2010, at 4:28 AM, rodo2...@googlemail.com wrote:
>> >
>> >> Hello everyone,
>> >> I just downloaded the implementation of the SPIN API 1.1.2 and  when
>> >> i run the example KennedysInferencingAndConstraintsExample i get an
>> >> StackOverflowError. I haven't changed anything in the source and i
>> >> think the problem is in this piece of code:
>> >>
>> >> ...
>> >> // Run constraints on a single instance only
>> >>   Resource person = cvs.get(0).getRoot();
>> >>   List localCVS =
>> SPINConstraints.check(person,
>> >> null);
>> >>   System.out.println("Constraint violations for " +
>> >> SPINLabels.get().getLabel(person) + ": " + localCVS.size());
>> >>
>> >> i am using jena 2.6.3 and ARQ  2.8.5. I would be very thankful for any
>> >> help.
>> >>
>> >> Regards
>> >> Rodolfo
>> >>
>> >> Console output:
>> >>
>> >> Inferred triples: 136
>> >> Constraint violations:
>> >> - at spin:AskTemplates:
>> >> - at spin:UpdateTemplates:
>> >> - at spin:SelectTemplates:
>> >> - at spin:ConstructTe

Re: [topbraid-users] [SPIN API] Loading SPIN constraints dynamically in to an ontology

2010-10-06 Thread Holger Knublauch
Hi Rudolfo,

I am not sure where the problem is in your example. I think I need more 
information - feel free to send me your specific example (off-list). I notice 
that you are creating the CONSTRUCT query but it is unclear whether this 
constraint is also attached to the model somehow.

Holger


On Oct 7, 2010, at 5:00 AM, Rodolfo Rieckhof wrote:

> Hello Holger, 
> thanks for your quick response. I have downloaded the new API and it works 
> just fine. But i have another question. 
> How can  i insert a SPIN constraint dynamically in my ontology ? I have tried 
> the following:
> I create a constraint, just like in the examples with:
> 
> ...
> String query = prefixes +
> "CONSTRUCT { _:b0 bad:deviceIngressProtection ?value;" +
> "  rdfs:label 'the value should be between 20 an 30'} " +
> "WHERE { ?dev rdf:type bad:Device ; bad:deviceIngressProtection ?value ." +
> "  FILTER ( ?value < 20 || ?value > 30) " +
> "}";
> 
> Query arqQuery = ARQFactory.get().createQuery(model, query);
> ARQ2SPIN arq2SPIN = new ARQ2SPIN(model);
> Construct spinQuery = (Construct) arq2SPIN.createQuery(arqQuery, null);
> 
> //then i load my Onotology
> 
> File root = new File("ontologies");
> String  dataURL = new File(root.getAbsolutePath() + 
> "/Thermokon_Easysens_Funkschalter_BJ_V1.owl").toURI().toString();
> Reasoner reasoner = PelletReasonerFactory.theInstance().create();
>   
>  // create an empty model
>OntModel ontModel = ModelFactory.createOntologyModel( 
> PelletReasonerFactory.THE_SPEC );
>ontModel.read( dataURL ); 
> 
> //add the   model with the Constraint 
> ontModel.addl(model);
> SPINModuleRegistry.get().registerAll(ontModel);
> 
> // let SPIN do its work
> List cvs = SPINConstraints.check(ontModel, null);
> System.out.println("Constraint violations:" + cvs.size());
> for(ConstraintViolation cv : cvs) {
> System.out.println(" - at " + SPINLabels.get().getLabel(cv.getRoot()) + ": " 
> + cv.getRoot());
> }
> 
> 
> the Problem is that i don´t get any constrains violation  (cvs = 0). Although 
> when i run the query with ARQ I get 1. Could you tell me please wich is the 
> wright way to do this ? . Is it a problem, that the is Ontology in rdf ? 
> 
> Regards,
> Rodolfo
> 
>  
> 
> 
> 2010/10/6 Holger Knublauch :
> > Hi Rodolfo,
> >
> > thanks a lot for this bug report. It was indeed a (simple) recursive loop. 
> > Since this was a small but rather critical bug, I have just updated the 
> > SPIN API that is on the web with a fix. The file has still the same version 
> > number etc, but the infinite loop should be gone now. I plan to do a proper 
> > release with a couple of new features in a few weeks after it went through 
> > QA.
> >
> > Thanks again
> > Holger
> >
> >
> > On Oct 6, 2010, at 4:28 AM, rodo2...@googlemail.com wrote:
> >
> >> Hello everyone,
> >> I just downloaded the implementation of the SPIN API 1.1.2 and  when
> >> i run the example KennedysInferencingAndConstraintsExample i get an
> >> StackOverflowError. I haven't changed anything in the source and i
> >> think the problem is in this piece of code:
> >>
> >> ...
> >> // Run constraints on a single instance only
> >>   Resource person = cvs.get(0).getRoot();
> >>   List localCVS = 
> >> SPINConstraints.check(person,
> >> null);
> >>   System.out.println("Constraint violations for " +
> >> SPINLabels.get().getLabel(person) + ": " + localCVS.size());
> >>
> >> i am using jena 2.6.3 and ARQ  2.8.5. I would be very thankful for any
> >> help.
> >>
> >> Regards
> >> Rodolfo
> >>
> >> Console output:
> >>
> >> Inferred triples: 136
> >> Constraint violations:
> >> - at spin:AskTemplates:
> >> - at spin:UpdateTemplates:
> >> - at spin:SelectTemplates:
> >> - at spin:ConstructTemplates:
> >> - at kennedys:JosephKennedy: age must be within a realistic range
> >> - at kennedys:StephenSmith: Same-sex marriage not permitted (in this
> >> model)
> >> - at kennedys:JeanKennedy: Same-sex marriage not permitted (in this
> >> model)
> >> Exception in thread "main" java.lang.StackOverflowError
> >>   at
> >> org.topbraid.spin.constraints.SPINConstraints.check(SPINConstraints.java:
> >> 259)
> >>   at
> >> org.topbraid.spin.constraints.SPINConstraints.check(SPINConstraints.java:
> >> 259)
> >> 
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Group "TopBraid Suite Users", the topics of which include TopBraid 
> >> Composer,
> >> TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
> >> To post to this group, send email to
> >> topbraid-users@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> topbraid-users+unsubscr...@googlegroups.com
> >> For more options, visit this group at
> >> http://groups.google.com/group/topbraid-users?hl=en
> >
> > --
> > You received this message because you are subscribed to the Google
> > Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
> > TopBraid Live, TopBraid Ensemble, SPARQ