Hi,

I'm currently on a R&D project and I try to develop a small program which 
allow to do :
- Load file.rdf
- Convert SPARQL construct query to SPIN rule. 
- Reason the file.rdf with the SPIN rule. 

So I already develop 2 java classes (attached).

1. I create Model and read my file.rdf.
2. I convert my construct query which is in a Model.
3. I add my Model which contain my SPIN Rule to my Data Model. 
4. I run Inference. 
5. Fail :(

Could you say me why it fail ? 


Best regards,
Simon.

-- 
You received this message because you are subscribed to the Google Group 
"TopBraid Suite Users", the topics of which include Enterprise Vocabulary 
Network (EVN), Reference Data Manager (RDM), TopBraid Composer, TopBraid Live, 
TopBraid Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to [email protected]
--- 
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/d/optout.
import org.apache.jena.query.Query;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.util.FileUtils;
import org.apache.jena.vocabulary.RDF;
import org.topbraid.spin.arq.ARQ2SPIN;
import org.topbraid.spin.arq.ARQFactory;
import org.topbraid.spin.model.Construct;
import org.topbraid.spin.system.SPINModuleRegistry;

public class spinConverter {

		public Model convert(){
			
			SPINModuleRegistry.get().init();
						
			Model model = ModelFactory.createDefaultModel();
			model.setNsPrefix("rdf", RDF.getURI());
			model.setNsPrefix("critic-cpu", "http://www.semanticweb.org/simonfarde/critic-cpu#";);
			model.setNsPrefix("base", "http://www.semanticweb.org/simonfarde/critic-cpu";);
			model.setNsPrefix("owl", "http://www.w3.org/2002/07/owl#";);
			
			String query =
					"CONSTRUCT {"+
							"?cpu critic-cpu:aPour critic-cpu:critic2 ."+
							"}"+
							"WHERE {"+
							"?cpu critic-cpu:chargeCPU ?x ."+
							"FILTER (?x >= 1) ."+
							"}";
							
			
			Query arqQuery = ARQFactory.get().createQuery(model, query);
			ARQ2SPIN arq2SPIN = new ARQ2SPIN(model);
			Construct spinQuery = (Construct) arq2SPIN.createQuery(arqQuery, null);
			
			
//			model.write(System.out, FileUtils.langXML);
			
			return model;
		}
}
import org.apache.jena.ontology.OntModel;
import org.apache.jena.ontology.OntModelSpec;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.util.FileUtils;
import org.topbraid.spin.inference.SPINInferences;
import org.topbraid.spin.system.SPINModuleRegistry;
import org.topbraid.spin.util.JenaUtil;

public class spinMain {

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

		// Load main file
		Model baseModel = ModelFactory.createDefaultModel();
		baseModel.read("criticcpu.rdf");
		
		spinConverter converter = new spinConverter();
		Model modelRule = converter.convert();
		baseModel.add(modelRule);
		
		baseModel.write(System.out, FileUtils.langXMLAbbrev);
		
		// Create OntModel with imports
		OntModel ontModel = JenaUtil.createOntologyModel(OntModelSpec.OWL_MEM,baseModel);
		
		// Create and add Model for inferred triples
		Model newTriples = ModelFactory.createDefaultModel();
		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());

	}
}

Attachment: criticcpu.rdf
Description: application/rdf

Reply via email to