How to run select type of rules from java program

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to run select type of rules from java program

Vivekanandan
Hi All,
I am pretty new to SWRL.
I have written the following code in java
When i tried to execute it,this results in the exception
In Catch 1.1 - edu.stanford.smi.protegex.owl.swrl.parser.SWRLParseException: Invalid atom name 'query:selectDistinct'.

how to retrieve the the individual ?z from the ontology
kindly help me

String uri = "file:/C:/Users/Administrator/Documents/Type/Test/src/test/IP.owl";
        try 
        {
            JenaOWLModel owlModel = null;
            owlModel = ProtegeOWL.createJenaOWLModelFromURI(uri);
            SWRLRuleEngineBridge bridge = null; 
            bridge = BridgeFactory.createBridge("SWRLJessBridge",owlModel);
            bridge.run(); 
            bridge.infer(); 
            SWRLFactory factory = new SWRLFactory(owlModel); 
            SWRLImp imp = factory.createImp("lives_in(?x, ?y)  ∧  is_located_in(?y, ?z) → resides_in(?x, ?z)  ∧  Person(?x)  ∧  query:selectDistinct(?z)");
            Collection col = imp.getDifferentFrom();
            for (Iterator it = col.iterator(); it.hasNext();)
            {
                try
                {
                     SimpleInstance cls = (SimpleInstance) it.next();
                }
                catch(Exception e)
                {
                     System.out.println("In Catch 1.0 - "+e);
                } 
           }
        }
        catch(Exception e)
        {
            System.out.println("In Catch 1.1 - "+e);
        } 
--
Regards,
Vivekanandan Ramachandran.

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: How to run select type of rules from java program

Martin O'Connor-2

It looks like you are using a very old version of the SWRLAPI.

I would use the latest 2.0.6 version: https://github.com/protegeproject/swrlapi/wiki

Martin


On Mar 22, 2019, at 3:31 AM, Vivekanandan <[hidden email]> wrote:

Hi All,
I am pretty new to SWRL.
I have written the following code in java
When i tried to execute it,this results in the exception
In Catch 1.1 - edu.stanford.smi.protegex.owl.swrl.parser.SWRLParseException: Invalid atom name 'query:selectDistinct'.

how to retrieve the the individual ?z from the ontology
kindly help me

String uri = "file:/C:/Users/Administrator/Documents/Type/Test/src/test/IP.owl";
        try 
        {
            JenaOWLModel owlModel = null;
            owlModel = ProtegeOWL.createJenaOWLModelFromURI(uri);
            SWRLRuleEngineBridge bridge = null; 
            bridge = BridgeFactory.createBridge("SWRLJessBridge",owlModel);
            bridge.run(); 
            bridge.infer(); 
            SWRLFactory factory = new SWRLFactory(owlModel); 
            SWRLImp imp = factory.createImp("lives_in(?x, ?y)  ∧  is_located_in(?y, ?z) → resides_in(?x, ?z)  ∧  Person(?x)  ∧  query:selectDistinct(?z)");
            Collection col = imp.getDifferentFrom();
            for (Iterator it = col.iterator(); it.hasNext();)
            {
                try
                {
                     SimpleInstance cls = (SimpleInstance) it.next();
                }
                catch(Exception e)
                {
                     System.out.println("In Catch 1.0 - "+e);
                } 
           }
        }
        catch(Exception e)
        {
            System.out.println("In Catch 1.1 - "+e);
        } 
--
Regards,
Vivekanandan Ramachandran.
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user