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

Naruepon Panawong jnaruepon.p at gmail.com
Fri Feb 21 20:52:42 PST 2014


Thank you for your recommend. I edit my code and run but error.....

                SWRLRuleEngine ruleEngine =
P3SWRLRuleEngineFactory.create("Jess", owlModel);
                OWLNamedClass touristClass =
owlModel.getOWLNamedClass("Tourist");
OWLObjectProperty ageProperty =
owlModel.getOWLObjectProperty("hasAgeRank");
 OWLIndividual individual1 = touristClass.createOWLIndividual("Person1");
individual1.setPropertyValue(ageProperty, "Age19-25");
 SWRLFactory factory = new SWRLFactory(owlModel);
factory.enableAll();
 SWRLImp imp = factory.createImp("Tourist(?x) ^ hasAgeRank(?x,Age19-25) ^
Waterfall(?a) -> hasAttraction(?x,?a)");
imp.enable();
 ruleEngine.infer();  // This error (How I do fix it?)

Exception in thread "main" java.lang.NullPointerException
at
org.protege.owl.portability.p3.converters.P3OWLAxiomConverter.completeBulkConversion(Unknown
Source)
at
org.protege.swrlapi.core.impl.AbstractSWRLRuleEngine.writeInferredKnowledge2OWL(Unknown
Source)
at org.protege.swrlapi.core.impl.AbstractSWRLRuleEngine.infer(Unknown
Source)


and I change ruleEngine.infer(); to
            ruleEngine.reset();
ruleEngine.importSWRLRulesAndOWLKnowledge();
ruleEngine.run();

Program show all data. I want to show Waterfall only.

Thank you and Best Regards.
Naruepon.p




2014-02-21 11:41 GMT+07:00 Martin O'Connor <martin at zippyrate.com>:

>
> 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
>
>
>
> _______________________________________________
> 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/20140222/4b6d18df/attachment.html>


More information about the protege-dev mailing list