Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-dev] Protege-API 3.5 - Help me please

Martin O'Connor martin at zippyrate.com
Thu Feb 20 20:41:23 PST 2014


You should not need the following:

> P3SWRLRuleEngineFactory.registerRuleEngine(JessNames.PluginName, new JessSWRLRuleEngineCreator());		


Rule engine registration (for Drools and Jess) happens automatically.

Also, SWRL and SQWRL are designed to work with OWL. You are creating RDF individuals in the following, which are likely to be ignored by SWRL and SQWRL:

		RDFIndividual individual1 = aClass.createRDFIndividual("Person1");
		individual1.setPropertyValue(ageProperty, "Age19-25");

The following is completely invalid (and should generate an exception):

	SWRLImp imp = factory.createImp("Q1","rule”);

“rule” is not a valid SWRL rule or SQWRL query.

If you want to create a SQWRL query you should do something like:

	SQWRLQueryEngine queryEngine = P3SQWRLQueryEngineFactory.create(owlModel); 
	queryEngine.createSQWRLQuery("Query-2", "Person(?p)-> sqwrl:select(?p)");

Martin

On Feb 20, 2014, at 7:54 PM, Naruepon Panawong <jnaruepon.p at gmail.com> wrote:

> I use Protege 3.5 for design my ontology and I use protege api (swrl) for
> rule engine. 
> 
> Some code and Question
>                 String uri ="filename";
> 		OWLModel owlModel = ProtegeOWL.createJenaOWLModelFromURI(uri);
> 		LocalFolderRepository rep = new LocalFolderRepository(new File("filename"),true); 
> 		owlModel.getRepositoryManager().addGlobalRepository(rep);
> 		owlModel.getNamespaceManager().setDefaultNamespace("http://www.owl-ontologies.com/xxxxxxxx.owl#");
> 		owlModel.getNamespaceManager().setPrefix("sqwrl","http://sqwrl.stanford.edu/ontologies/built-ins/3.4/sqwrl.owl#");
> 		owlModel.getNamespaceManager().setPrefix("swrl","http://www.w3.org/2003/11/swrl#");
> 		owlModel.getNamespaceManager().setPrefix("xsp","http://www.owl-ontologies.com/2005/08/07/xsp.owl#");
> 		owlModel.getNamespaceManager().setPrefix("swrlb","http://www.w3.org/2003/11/swrlb#");
> 		owlModel.getNamespaceManager().setPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");
> 		owlModel.getNamespaceManager().setPrefix("xsd","http://www.w3.org/2001/XMLSchema#");
> 		owlModel.getNamespaceManager().setPrefix("rdfs","http://www.w3.org/2000/01/rdf-schema#");
> 		owlModel.getNamespaceManager().setPrefix("owl","http://www.w3.org/2002/07/owl#");
> 
>                 P3SWRLRuleEngineFactory.registerRuleEngine(JessNames.PluginName, new JessSWRLRuleEngineCreator());
> 		SWRLRuleEngine ruleEngine = P3SWRLRuleEngineFactory.create(JessNames.PluginName, owlModel);
> 		
>                 OWLNamedClass aClass = owlModel.getOWLNamedClass("A"); 
> 		OWLObjectProperty ageProperty = owlModel.getOWLObjectProperty("hasA"); 
> 		
> 		RDFIndividual individual1 = aClass.createRDFIndividual("Person1");
> 		individual1.setPropertyValue(ageProperty, "Age19-25");
> 		
> 		SWRLFactory factory = new SWRLFactory(owlModel);
> 		factory.enableAll();
> 		
> 		SWRLImp imp = factory.createImp("Q1","rule");
> 		imp.enable();
> 
>                 ruleEngine.infer();
> 
> Q1. Why I use ruleEngine.infer();   // Error, I can't fix it. (Can you send me for jar file that fix it?)
> 
>                 ruleEngine.reset();
>                 ruleEngine.importSWRLRulesAndOWLKnowledge();
>                 ruleEngine.run();
>         
> 		System.out.println("Infered axioms size="+ruleEngine.getNumberOfInferredOWLAxioms());
> 		System.out.println("\nInfered axioms ="+ruleEngine.getInferredOWLAxioms());
> 		System.out.println("Infered Individuals ="+ruleEngine.getNumberOfInferredOWLAxioms());	
> Q2. ruleEngine.infer(); --> Error I change new method, It return all Axioms (I want return by rule)
> 
> 
> Q3. How I resolve Invalid query name Q1
>                 ruleEngine.runSQWRLQueries();
> 		Result result = ruleEngine.getSQWRLResult("Q1");
> 
> Best Regards.
> Naruepon.
> _______________________________________________
> protege-dev mailing list
> protege-dev at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-dev/attachments/20140220/1475a7bf/attachment-0001.html>


More information about the protege-dev mailing list