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-owl] Create Rules in Eclipse using Protege 3.4.4

aros aros at fotonik.dtu.dk
Wed Jul 21 04:08:03 PDT 2010


Hi Jean-Marc,

Thanks for the fast reply. Here is the ontology plus a simple SWRL rule. This ontology is a very simple ontology that I have been using to test SWRL rules and Jess. It has only 2 individuals and one rule (the ones mentioned in the post).

In my java program I am using Protégé 3.4.4 to create new individuals and retrieve information of the ontology (like what properties does a class have). I use Jess to execute SWRL queries. This queries are usually done to retrieve information about individuals (mainly properties and the individuals link by the properties). So I am interested that my RuleEngine works with the some ontology and that if a rule is executed it makes the modifications in my ontology, so when I query it I obtain the correct values and not the initial values.

Thanks a lot,
Best Regards,


Ana Rossello Busquet

Ph.D. Student

Networks Technology and Service Platforms

DTU Fotonik



Technical University of Denmark

[cid:image001.gif at 01CB28D4.772A74C0]

Department of Photonics Engineering

Ørsteds Plads

Building 343

2800  Kgs. Lyngby

Direct +45 45256380
Mob. +45 2830 0805

aros at fotonik.dtu.dk<mailto:aros at fotonik.dtu.dk>

www.fotonik.dtu.dk<http://www.fotonik.dtu.dk/>



From: Jean-Marc Vanel [via Protege Ontology Editor & Knowledge Acquisition System] [mailto:ml-node+2296869-1512852327-267499 at n4.nabble.com]
Sent: 21. juli 2010 12:09
To: Ana Rossello Busquet
Subject: Re: Create Rules in Eclipse using Protege 3.4.4

Hi Aros
The problem is that OWL API is not meant to manage dynamic changes, it
is an monotonic logic
(http://en.wikipedia.org/wiki/Non-monotonic_logic).
Your function changeMyState() calls OWLIndividual.setPropertyValue() ;
you must understand this as "add Property Value pair to the existing
set of Property Value pairs". In OWL API (and SWRL) there is no method
replaceValue().

The underlying JESS engine, being a RETE engine, probably manages
replacement and deletion of Values. But SWRL not, by specification.

The N3 engine of EulerGUI (also an SWRL engine by translation of rule
languages) exposes the non-monotonic features of the underlying RETE
engine (Drools).

If you send me your OWL+SWRL ontology, I can play with it in EulerGUI,
and report that.

2010/7/21 aros <[hidden email]</user/SendEmail.jtp?type=node&node=2296869&i=0>>:

>
> Hi,
>
> I tried to use Jess to implement some SWRL rules but I am getting some
> errors. It seems like I cannot change the value of Dataproperties, instead
> it creates a second value for the dataproperty. After executing the rule the
> dataproperty has 2 possible values. In my ontology I defined that the class
> should have exactly 1
>
> My ontology is as follows:
> -Class Lamp: has the following properties: hasControl (Object property with
> range class Switch, and has exactly 1), hasState (Dataproperty with Range
> String, and has exactly 1)
> -Class Switchhas teh following properties: isControlof (Object property with
> range class Lamp), hasState (Dataproperty with range String, and has exactly
> 1)
>
> I create 2 individuals:
> -Lamp1, with hasControl Switch1 and hasState Off
> -Switch1, with isControlOf Lamp1 and hasState Off
>
> My rule is as follows: lamp1 should be in the same state as switch1
> (if switch1 hasState off then lamp1 hasState off)
>
> My Java program (I ommited try and catch):
>
> //load ontology
> FileReader owlFile = new FileReader(filepath);
> JenaOwlModel owlModel = ProtegeOWL.createJenaOWLModelFromReader(owlFile);
>
> //factory for SWRL Queries
> factory = new SQWRLQueryEngineFactory();
> queryEngine = SQWRLQueryEngineFactory.create(owlModel);
>
> //Query to retrive state of lamp and switch
> String query = new String("hasState(?dev, ?state)-> sqwrl:select(?dev,
> ?state)");
> queryEngine.runSQWRLQuery("getStateQuery", query);
> runMyQuery2("getStateQuery"); //function included at the end
>
> //Creating Jess rule Engine
> SWRLRuleEngineBridge bridge =
> BridgeFactory.createBridge("SWRLJessBridge",owlModel);
> SWRLFactory factory2 = new SWRLFactory(owlModel);
>
> //crerating rule
> SWRLImp imp = factory2.createImp("Control_lamp", "Lamp(?lamp) ^
> hasControl(?lamp, ?control)  ^ hasState(?control, ?statecontrol) ->
> hasState(?lamp, ?statecontrol)");
> bridge.infer();
>
> //change status of switch and check the devices status
> changeMyState("switch1", "Off"); //function included at the end
> runMyQuery2("getStateQuery");
>
>
> //fucntion to retrive query results (i ommited try and catch)
> public void runMyQuery2(String query){
>        SQWRLResult result =  queryEngine.runSQWRLQuery(query);
>        while (result.hasNext()) {
>                String uri = result.getObjectValue("?dev").toString();
>                String value = result.getDataValue("?state").toString();
>                String[] tokens = uri.split("[#]");
>                System.out.println(tokens[1]+": "+value);
>                result.next();
> }
>
>
> //function to change status
> public void changeMyState(String dev, String state){
>        OWLIndividual ind = owlModel.getOWLIndividual(myBaseUri+dev);
>        OWLProperty prop = owlModel.getOWLProperty(myBaseUri+"hasState");
>        ind.setPropertyValue(prop, state);
> }
>
> And here is my console:
>
> Loading triples for: null
>    Completed triple loading after 265 ms
> Importing http://sqwrl.stanford.edu/ontologies/built-ins/3.4/sqwrl.owl from
> location: M:\eclipse\eclipse\plugins\edu.stanford.smi.protegex.owl\sqwrl.owl
> 21-07-2010 10:43:02
> edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel
> loadImportedAssertions
> INFO: Importing http://sqwrl.stanford.edu/ontologies/built-ins/3.4/sqwrl.owl
> from location:
> M:\eclipse\eclipse\plugins\edu.stanford.smi.protegex.owl\sqwrl.owl
> Loading triples for:
> http://sqwrl.stanford.edu/ontologies/built-ins/3.4/sqwrl.owl
>    Completed triple loading after 0 ms
> Importing http://swrl.stanford.edu/ontologies/3.3/swrla.owl from location:
> M:\eclipse\eclipse\plugins\edu.stanford.smi.protegex.owl\swrla.owl
> 21-07-2010 10:43:02
> edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel
> loadImportedAssertions
> INFO: Importing http://swrl.stanford.edu/ontologies/3.3/swrla.owl from
> location: M:\eclipse\eclipse\plugins\edu.stanford.smi.protegex.owl\swrla.owl
> Loading triples for: http://swrl.stanford.edu/ontologies/3.3/swrla.owl
>    Completed triple loading after 15 ms
> Postprocess: Process entities with incorrect Java type (0 entities) ... 0 ms
> Postprocess: Process metaclasses (3 metaclasses) ... 0 ms
> Postprocess: Process subclasses of rdf:List (1 classes) ... 0 ms
> Postprocess: Instances with multiple types (15 instances) ... 0 ms
> Postprocess: Add inferred superclasses ... 0 ms
> Postprocess: Process orphan classes (9 classes) ... 0 ms
> Postprocess: Generalized Concept Inclusion (0 axioms) ... 0 ms
> Postprocess: Abstract classes... 0 ms
> Postprocess: Domain and range of properties... 0 ms
> Postprocess: Possibly typed entities (0 resources) ... 0 ms
> Updating underlying frames model in 0 ms
> 21-07-2010 10:43:03
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser
> doFinalPostProcessing
> INFO: Updating underlying frames model in 0 ms
> Rule engine 'SWRLJessBridge' registered with the SWRLTab bridge.
> 21-07-2010 10:43:03 edu.stanford.smi.protegex.owl.swrl.bridge.BridgeFactory
> registerBridge
> INFO: Rule engine 'SWRLJessBridge' registered with the SWRLTab bridge.
>
> //Result of the getStateQuery, The devices have one value for hasState
> property
> switch1: On
> lamp1: On
>
> WARNING: [OWLFrameStore] Warning: Attempted to assign duplicate value to
> lamp1.hasState -- DuplicateValuesFrameStore.setDirectOwnSlotValues()
> 21-07-2010 10:43:04
> edu.stanford.smi.protegex.owl.model.framestore.DuplicateValuesFrameStore
> setDirectOwnSlotValues
> WARNING: [OWLFrameStore] Warning: Attempted to assign duplicate value to
> lamp1.hasState
> WARNING: [OWLFrameStore]  - On --
> DuplicateValuesFrameStore.setDirectOwnSlotValues()
> 21-07-2010 10:43:04
> edu.stanford.smi.protegex.owl.model.framestore.DuplicateValuesFrameStore
> setDirectOwnSlotValues
> WARNING: [OWLFrameStore]  - On
> WARNING: [OWLFrameStore]  - On --
> DuplicateValuesFrameStore.setDirectOwnSlotValues()
> 21-07-2010 10:43:04
> edu.stanford.smi.protegex.owl.model.framestore.DuplicateValuesFrameStore
> setDirectOwnSlotValues
> WARNING: [OWLFrameStore]  - On
>
> //Result of the getStateQuery, The lamp1 has 2 values for hasState property
> lamp1: Off
> switch1: Off
> lamp1: On
>
>
> I also tried to run these two rules instead:
> SWRLImp imp = factory2.createImp("Control_lamp_Off", "Light(?lamp) ^
> hasControl(?lamp, ?control)  ^ hasState(?control, ?statecontrol)^
> swrlb:equal(?statecontrol, \"Off\") -> hasState(?lamp, \"Off\")");
> SWRLImp imp2 = factory2.createImp("Control_lamp_On", "Light(?lamp) ^
> hasControl(?lamp, ?control) ^ hasState(?control, ?statecontrol)^
> swrlb:equal(?statecontrol, \"On\") -> hasState(?lamp, \"On\")");
>
>
> but I got the same result. Am I doing something wrong? Or is it not possible
> to use SWRL rules and Jess to change dataproperties values??
>
> Will I have the same problem if I try to use EulerGUI?
>
> I have been looking around and there are a lot of rule engines, RuleML,
> Sweetrules, etc. Which one do you recomment to work together with my
> ontology? EulerGui?
>
> Thanks,
> Ana
> --
> View this message in context: http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/Create-Rules-in-Eclipse-using-Protege-3-4-4-tp2288368p2296808.html<http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/Create-Rules-in-Eclipse-using-Protege-3-4-4-tp2288368p2296808.html?by-user=t>
> Sent from the Protege OWL mailing list archive at Nabble.com.
> _______________________________________________
> protege-owl mailing list
> [hidden email]</user/SendEmail.jtp?type=node&node=2296869&i=1>
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>



--
Jean-Marc Vanel
Consulting, services, training,
Rule-based programming, Semantic Web
http://jmvanel.free.fr/
EulerGUI, a turntable GUI for Semantic Web + rules, XML, UML, eCore,
Java bytecode
+33 (0)6 89 16 29 52 -- +33 (0)1 39 55 58 16
( we rarely listen to voice messages, please send a mail instead )
_______________________________________________
protege-owl mailing list
[hidden email]</user/SendEmail.jtp?type=node&node=2296869&i=2>
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

________________________________
View message @ http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/Create-Rules-in-Eclipse-using-Protege-3-4-4-tp2288368p2296869.html
To unsubscribe from Re: Create Rules in Eclipse using Protege 3.4.4, click here<http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/subscriptions/Unsubscribe.jtp?code=YXJvc0Bmb3RvbmlrLmR0dS5ka3wyMjk2ODA4fC0yMTc5MTQ5NDk=>.


 
 
-- 
View this message in context: http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/Create-Rules-in-Eclipse-using-Protege-3-4-4-tp2288368p2296938.html
Sent from the Protege OWL mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-owl/attachments/20100721/dc154eaa/attachment.html>


More information about the protege-owl mailing list