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 02:10:47 PDT 2010


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
Sent from the Protege OWL mailing list archive at Nabble.com.



More information about the protege-owl mailing list