Hi Jeff,

sorry for the late response and thanks for adjusting the subject line.

I tried the "same" like you but it works fine for me. See code below -  
the standard example from the SPIN API, but with the spinsquare  
ontology as example.

I can only speculate what could be the issue. Maybe you have created  
the Model with some Jena inferencing mode on, or some implicit imports  
(check the OntDocumentManager).

And to copy our friends from the helpful Jena mailing list, "a  
complete, minimal example would help :)

Holger


package org.topbraid.spin.examples;

import java.util.List;

import org.topbraid.spin.constraints.ConstraintViolation;
import org.topbraid.spin.constraints.SPINConstraints;
import org.topbraid.spin.inference.SPINInferences;
import org.topbraid.spin.system.SPINLabels;
import org.topbraid.spin.system.SPINModuleRegistry;

import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.shared.ReificationStyle;
import com.hp.hpl.jena.util.FileUtils;


/**
  * Loads the Kennedys SPIN ontology and runs inferences and then
  * constraint checks on it.
  *
  * @author Holger Knublauch
  */
public class KennedysInferencingAndConstraintsExample {

        public static void main(String[] args) {
                
                // Initialize system functions and templates
                SPINModuleRegistry.get().init();

                // Load main file
                Model baseModel =  
ModelFactory.createDefaultModel(ReificationStyle.Minimal);
                baseModel.read("http://topbraid.org/examples/spinsquare.n3";,  
FileUtils.langN3);
                
                // Create OntModel with imports
                OntModel ontModel =  
ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, baseModel);
                
                // Create and add Model for inferred triples
                Model newTriples =  
ModelFactory.createDefaultModel(ReificationStyle.Minimal);
                ontModel.addSubModel(newTriples);

                // Register locally defined functions
                SPINModuleRegistry.get().registerAll(ontModel);

                // Run all inferences
                SPINInferences.run(ontModel, newTriples, null, null, false, 
null);
                System.out.println("Inferred triples: " + newTriples.size());

                // Run all constraints
                List<ConstraintViolation> cvs = SPINConstraints.check(ontModel, 
null);
                System.out.println("Constraint violations:");
                for(ConstraintViolation cv : cvs) {
                        System.out.println(" - at " +  
SPINLabels.get().getLabel(cv.getRoot()) + ": " + cv.getMessage());
                }

                // Run constraints on a single instance only
                Resource person = cvs.get(0).getRoot();
                List<ConstraintViolation> localCVS = 
SPINConstraints.check(person,  
null);
                System.out.println("Constraint violations for " +  
SPINLabels.get().getLabel(person) + ": " + localCVS.size());
        }
}


On Aug 10, 2009, at 2:11 PM, Schmitz, Jeffrey A wrote:

>
> Re-posting with proper subject...
>
> Hello,
>   Using the SPIN libraries, I'm trying to run constraint checking on
> the example spinsquare model mentioned here:
>
> http://composing-the-semantic-web.blogspot.com/2009_01_01_archive.html
>
> When I run the following code on the model:
>
>               List<ConstraintViolation> cvs =
> SPINConstraints.check(spinsquareModel, null);
>               for (ConstraintViolation cv : cvs) {
>                       logIt("Constraint violations:");
>                       logIt(" - at "
>                                       +
> SPINLabels.get().getLabel(cv.getRoot()) + ": "
>                                       + cv.getMessage());
>               }
>
> I do get the invalid square constraint error returned, however I also
> get a LOT of ConstraintViolation objects returned that reference
> anonymous nodes with no associated message.  E.g. the output from the
> above code is
>
> Constraint violations:
>
> - at :InvalidSquare: Width and height of a Square must be equal
> Constraint violations:
> - at -eaa82cc:123049a7331:-7ea7:
> Constraint violations:
> - at -eaa82cc:123049a7331:-7e99:
> Constraint violations:
> - at -eaa82cc:123049a7331:-7e88:
> Constraint violations:
> - at -eaa82cc:123049a7331:-7edc:
> Constraint violations:
> - at -eaa82cc:123049a7331:-7eee:
> Constraint violations:
> - at -eaa82cc:123049a7331:-7ece:
>
>
> And there are many more anonymous node violations returned.   Any idea
> what may be causing this?
>
> Thanks,
> Jeff
>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TopBraid Composer Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/topbraid-composer-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to