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] making of changed data type properties at run time (in SWRL rule)

Zhang Weishan dr_zhangws at yahoo.com
Mon Jan 11 08:00:26 PST 2010


Hello Timothy,
  Thanks for your reply. Sorry for the incomplete code. I have sent you (to your university email) a link on all the code (OSGi bundles with felix, which are going to be released to the public) including the ontologies. 
  In my tests, i only have one swrl rule which will not generate large number of events, and i also filtered out the properties listened. The workflow: make changes to a property value, listen for changes, and inferring swrl rules worked well in my former prototypes running wiht plain JSE.

  Thanks for taking a look at it,

  Best regards,
  Weishan





________________________________
From: Timothy Redmond <tredmond at stanford.edu>
To: User support for the Protege-OWL editor <protege-owl at lists.stanford.edu>
Sent: Sun, January 10, 2010 2:16:18 PM
Subject: Re: [protege-owl] making of changed data type properties at run time (in SWRL rule)


I am sorry.  I haven't actually succeeding in understanding the issue precisely.  It is possible that your issue is related to the fact that if you are listening for events during swrl processing you will no longer hear them during swrl inference.  This was done because swrl inference can generate a large number of events and for the most part event listeners are doing gui style work.  It is quicker to reset the gui after the swrl inferencing than to pay the overhead of event processing.

I tried to compile your code and had trouble with the OWLModelFromRepository, OWLModelHandler classes and the setProperty method.

-Timothy

Zhang Weishan wrote:
> Sorry to have to post and rename the title, but there is no response regarding my question?
> 
> Thanks,
> Weishan
> 
> ------------------------------------------------------------------------
> *From:* Zhang Weishan <dr_zhangws at yahoo.com>
> *To:* protege-owl at lists.stanford.edu
> *Sent:* Wed, January 6, 2010 10:26:05 PM
> *Subject:* Re: reading changed properties in memory and then used to reason using SWRL rule
> 
> Any ideas on my problem?
> 
> Best,
> Weishan
> 
> ------------------------------------------------------------------------
> *From:* Zhang Weishan <dr_zhangws at yahoo.com>
> *To:* protege-owl at lists.stanford.edu
> *Sent:* Tue, December 29, 2009 10:42:45 PM
> *Subject:* reading changed properties in memory and then used to reason using SWRL rule
> 
> Dear All,
>    I was using the property change listener before to listen for the changed value for a property, and then make use of the changed value to reason using SWRL rules. It was working well before (using protege before V3.4). But now i got a problem with this working flow: the property value change listener can detect the changes in the property value, the problem is that the SWRL rule can not get the updated value to make decisions.
> 
> public void propertyValueChanged(RDFResource resource,
>                 RDFProperty property, Collection oldValues) {
> 
>             HashSet<String> inferred = new HashSet<String>();
>     //        System.out.println(" notified for properties changed"+property.getBrowserText());
> /*            System.out.println("Resource = " + resource.getBrowserText());
>             System.out.println("Property = " + property.getBrowserText());
>             System.out.println("oldValues = " + oldValues);*/
> //execution of a swrl rule to make use of the new value
>   ....
> }
> 
> 
> I also tried to see whether the property is updated correctly and can be used after a change, something also a bit strange: i got a null from the update (but in setProperty(hardware, property, level), i can see that the property is changed ).
> 
> public class BatteryLevelUpdate{
>        private OWLModel protocolModel=null;
>     public BatteryLevelUpdate(OWLModel model, String hardwareURI){
>         OWLModelHandler.swapTripleStore(model, hardwareURI);
>     }
>         /**
>      * Sets the property to the instance in the related TripleStore
>      * @param owlmodel The core OWLModel.
>      * @param deviceURI The device URI.
>      * @param level The level of device battery.
>      */
>           public void updateBatteryLevel(OWLModel owlmodel, String deviceURI, float level){
>               String uri=owlmodel.getURIForResourceName("Battery");
> 
>         String prefixedNameDevice=owlmodel.getResourceNameForURI(deviceURI);
>                     OWLIndividual device=owlmodel.getOWLIndividual(prefixedNameDevice);
>                  String uriPropHardware=deviceURI.substring(0, deviceURI.indexOf("#")+1)+owlmodel.getResourceNameForURI("hasHardware");
>                  OWLProperty propertyHardware = owlmodel.getOWLProperty(uriPropHardware);
>                  OWLIndividual hardware=(OWLIndividual)device.getPropertyValue(propertyHardware);
> 
>                       String uriPropBatteryLevel=hardware.getURI().substring(0, hardware.getURI().indexOf("#")+1)+owlmodel.getResourceNameForURI("batteryLevel");
>  
>         OWLProperty property = owlmodel.getOWLProperty(uriPropBatteryLevel);
> 
>         setProperty(hardware, property, level);
>        //        System.out.println( "setting to: "+hardware.getPropertyValue(property));
>   /*      System.out.println("time taken to update battery level "+ (System.currentTimeMillis()-current));
>         inferred = ruleGroupP.inferRuleGroup(protocolModel, "protocol" );
>         System.out.println(" inferred "+inferred.size());*/
>        System.out.println("time taken to update battery level "+ (System.currentTimeMillis()-current));
>     }
>      
>         public static void main(String[] args) throws URISyntaxException {
>                              long current = System.currentTimeMillis();
>               OWLModel owlModelCore = OWLModelFromRepository.getOntologyModel( new URI("file:/C:/Users/zhang/workspace/os/sdk/flamenco/flamenco_semaps/semaps/repository/ProtocolAdaptation.owl")).getOWLModel();
>                                       BatteryLevelUpdate u=new BatteryLevelUpdate(owlModelCore, "http://localhost:9999/hydra/ontologies/Hardware.owl");
>                      u.updateBatteryLevel( owlModelCore, "http://localhost:9999/hydra/ontologies/Device.owl#motionSensor0_protocolAdaptation", 0.1f);
>                    OWLIndividual hardware=owlModelCore.getOWLIndividual("http://localhost:9999/hydra/ontologies/Hardware.owl#Battery_motionSensor0_protocolAdaptation");
>                 OWLProperty property = owlModelCore.getOWLProperty("http://localhost:9999/hydra/ontologies/Hardware.owl#batteryLevel");
>                    System.out.println("updated "+hardware+ " battery level "+ hardware.getPropertyValue(property));
>         }
>    }
> 
>  Did i make any mistakes?
> 
>  Thanks for reading and wish you a Happy New Year!
> 
> Best,
> Weishan
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> protege-owl mailing list
> protege-owl at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
> 
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>  

_______________________________________________
protege-owl mailing list
protege-owl at lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/protege-owl

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



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-owl/attachments/20100111/c37fbb25/attachment.html>


More information about the protege-owl mailing list