On 5/15/2013 17:32, Leo Anbarasan wrote:

This method return empty result. I have run this in topbraid composer. It works fine and return a result. I am not sure about it in API. Could give an example to execute SPIN function.

Your SPARQL syntax looks correct, and I don't have enough background to give more useful feedback here. Calling and registering SPIN functions is done by the OWLRL and the Kennedys Java code examples that come with the SPIN API download. Please take a look at those. I have attached the kennedys example snippet below.

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 org.topbraid.spin.util.JenaUtil;

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;


/**
 * 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/kennedysSPIN";);

        // Create OntModel with imports
OntModel ontModel = JenaUtil.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, null);

        // 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());
    }
}

--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary 
Network (EVN), TopBraid Composer, TopBraid Live,
TopBraid Ensemble, SPARQLMotion, SPARQL Web Pages and SPIN.
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-users?hl=en
--- You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to