Re: protege-dev Digest, Vol 26, Issue 2

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

Re: protege-dev Digest, Vol 26, Issue 2

lalit purohit
Hello!!!

Can anyone please answer the question I posted earlier. I will repeat the question
---------------------------------------------------------------------------------------------------------------------------
Matthew told to get the swrl rules from the ontology using following statement,

Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

However, compiler is saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule. 

Is there already any method available to compare two swrl rules, please let me know. I am not able to get any related material for using swrlapi to compare two SWRL rules generated using protege.


Thanks
-----------------------------------------------------------------------------------------------

On Thu, Mar 3, 2016 at 1:33 AM, <[hidden email]> wrote:
Send protege-dev mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://mailman.stanford.edu/mailman/listinfo/protege-dev
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of protege-dev digest..."


Today's Topics:

   1. Re: protege-dev Digest, Vol 26, Issue 1 (lalit purohit)


----------------------------------------------------------------------

Message: 1
Date: Wed, 2 Mar 2016 10:36:00 +0530
From: lalit purohit <[hidden email]>
To: [hidden email]
Subject: Re: [protege-dev] protege-dev Digest, Vol 26, Issue 1
Message-ID:
        <CAC8ugA8q67J3aWz_+KjEeM9uDNEwAR+AzXw=[hidden email]>
Content-Type: text/plain; charset="utf-8"

Hello!!!

Thanx for the reply. For the statement
Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

you told to get the swrl rules from the ontology, however, compiler is
saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule and trying to
compare with the equivalent part of another ontology. Therefore, please
tell the correct method to get the rule and extract the head and body part
of the ontology. Or if there already any method available to compare two
swrl rules, please let me know. I am not able to get any related material
for using swrlapi to compare two SWRL rules generated using protege.


Thanks


On Wed, Mar 2, 2016 at 1:33 AM, <[hidden email]>
wrote:

> Send protege-dev mailing list submissions to
>         [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> or, via email, send a message with subject or body 'help' to
>         [hidden email]
>
> You can reach the person managing the list at
>         [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of protege-dev digest..."
>
>
> Today's Topics:
>
>    1. Re: protege-dev Digest, Vol 25, Issue 6 (lalit purohit)
>    2. How to extract details of Axioms (lalit purohit)
>    3. Re: How to extract details of Axioms (Matthew Horridge)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 1 Mar 2016 11:01:04 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: Re: [protege-dev] protege-dev Digest, Vol 25, Issue 6
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello !!
>
> It seems that the SWRL rule posted by me was wrong (due to copy-paste). The
> correct rule is -
>
>
> City(?city) ^ hasInput(?HOTEL, ?city) ^ locatedIn(?city, ?COUNTRY) ->
> Reserve(?city, ?HOTEL)
>
> Q.1  Is this rule doing the intended task?
>
> Q2. Is there Jena / Protege-Owl API which reads predicates and arguments
> from the SWRL code in the owl file? Kindly provide the code snippet, if
> possible.
>
>
> Thanks for reply
>
>
> On Tue, Mar 1, 2016 at 1:33 AM, <[hidden email]>
> wrote:
>
> > Send protege-dev mailing list submissions to
> >         [hidden email]
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> > or, via email, send a message with subject or body 'help' to
> >         [hidden email]
> >
> > You can reach the person managing the list at
> >         [hidden email]
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of protege-dev digest..."
> >
> >
> > Today's Topics:
> >
> >    1. SWRL related help (lalit purohit)
> >    2. Re: SWRL related help (Martin O'Connor)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Mon, 29 Feb 2016 12:01:52 +0530
> > From: lalit purohit <[hidden email]>
> > To: [hidden email]
> > Subject: [protege-dev] SWRL related help
> > Message-ID:
> >         <CAC8ugA-7zWiymnem-WzWwuO=
> > [hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> user
> > inputs. If all user inputs and constraints (If any, like duration) are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> the
> > rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment
> > rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Check
> > city should be in country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> code?
> > A sample code, if anyone can quote to make the concept more
> understandable
> > will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/568c7969/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Mon, 29 Feb 2016 17:43:55 +0000
> > From: "Martin O'Connor" <[hidden email]>
> > To: Developer support for WebProtege and Protege Desktop
> >         <[hidden email]>
> > Subject: Re: [protege-dev] SWRL related help
> > Message-ID: <[hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> >
> > It is not clear that SWRL is suited to the type of task you outline. SWRL
> > and OWL perform monotonic inference. It seems unlikely that you want the
> > hotels that satisfy the antecedent to be reserved forever. See:
> >
> >
> >
> https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ#does-swrl-support-nonmonotonic-inference
> >
> > Martin
> >
> > On Feb 28, 2016, at 10:31 PM, lalit purohit <[hidden email]
> > <mailto:[hidden email]>> wrote:
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> > user inputs. If all user inputs and constraints (If any, like duration)
> are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> > the rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#string">Check city should be in
> > country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> > code? A sample code, if anyone can quote to make the concept more
> > understandable will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> >
> >
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]<mailto:[hidden email]>
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/d4fc8edc/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Subject: Digest Footer
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> >
> > ------------------------------
> >
> > End of protege-dev Digest, Vol 25, Issue 6
> > ******************************************
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/28233589/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Tue, 1 Mar 2016 20:40:18 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: [protege-dev] How to extract details of Axioms
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/0f27153a/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 3
> Date: Tue, 1 Mar 2016 16:52:08 +0000
> From: Matthew Horridge <[hidden email]>
> To: Developer support for WebProtege and Protege Desktop
>         <[hidden email]>
> Subject: Re: [protege-dev] How to extract details of Axioms
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> To get the SWRLRules you can just use:
>
>
> Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);
>
> What parts of the rule do you want and what do you want to do with them?
>
> You can use the getHead and getBody methods to get atoms in the head and
> body.
>
> Cheers,
>
> Matthew
>
>
> On 1 Mar 2016, at 07:10, lalit purohit <[hidden email]<mailto:
> [hidden email]>> wrote:
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> _______________________________________________
> protege-dev mailing list
> [hidden email]<mailto:[hidden email]>
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/8df10f4b/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
>
> ------------------------------
>
> End of protege-dev Digest, Vol 26, Issue 1
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160302/176e1572/attachment-0001.html>

------------------------------

Subject: Digest Footer

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


------------------------------

End of protege-dev Digest, Vol 26, Issue 2
******************************************


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

Re: protege-dev Digest, Vol 26, Issue 2

Matthew Horridge-2
Administrator
Hi,

I must have mistyped the original code.  It should be:

Set<SWRLRule> rules = ont.getAxioms(AxiomType.SWRL_RULE);

It’s not clear what you mean by “compare”.  If you could provide an example that might help.


Cheers,

Matthew


On 5 Mar 2016, at 21:50, lalit purohit <[hidden email]> wrote:

Hello!!!

Can anyone please answer the question I posted earlier. I will repeat the question
---------------------------------------------------------------------------------------------------------------------------
Matthew told to get the swrl rules from the ontology using following statement,

Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

However, compiler is saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule. 

Is there already any method available to compare two swrl rules, please let me know. I am not able to get any related material for using swrlapi to compare two SWRL rules generated using protege.


Thanks
-----------------------------------------------------------------------------------------------

On Thu, Mar 3, 2016 at 1:33 AM, <[hidden email]> wrote:
Send protege-dev mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://mailman.stanford.edu/mailman/listinfo/protege-dev
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of protege-dev digest..."


Today's Topics:

   1. Re: protege-dev Digest, Vol 26, Issue 1 (lalit purohit)


----------------------------------------------------------------------

Message: 1
Date: Wed, 2 Mar 2016 10:36:00 +0530
From: lalit purohit <[hidden email]>
To: [hidden email]
Subject: Re: [protege-dev] protege-dev Digest, Vol 26, Issue 1
Message-ID:
        <CAC8ugA8q67J3aWz_+KjEeM9uDNEwAR+AzXw=[hidden email]>
Content-Type: text/plain; charset="utf-8"

Hello!!!

Thanx for the reply. For the statement
Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

you told to get the swrl rules from the ontology, however, compiler is
saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule and trying to
compare with the equivalent part of another ontology. Therefore, please
tell the correct method to get the rule and extract the head and body part
of the ontology. Or if there already any method available to compare two
swrl rules, please let me know. I am not able to get any related material
for using swrlapi to compare two SWRL rules generated using protege.


Thanks


On Wed, Mar 2, 2016 at 1:33 AM, <[hidden email]>
wrote:

> Send protege-dev mailing list submissions to
>         [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> or, via email, send a message with subject or body 'help' to
>         [hidden email]
>
> You can reach the person managing the list at
>         [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of protege-dev digest..."
>
>
> Today's Topics:
>
>    1. Re: protege-dev Digest, Vol 25, Issue 6 (lalit purohit)
>    2. How to extract details of Axioms (lalit purohit)
>    3. Re: How to extract details of Axioms (Matthew Horridge)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 1 Mar 2016 11:01:04 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: Re: [protege-dev] protege-dev Digest, Vol 25, Issue 6
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello !!
>
> It seems that the SWRL rule posted by me was wrong (due to copy-paste). The
> correct rule is -
>
>
> City(?city) ^ hasInput(?HOTEL, ?city) ^ locatedIn(?city, ?COUNTRY) ->
> Reserve(?city, ?HOTEL)
>
> Q.1  Is this rule doing the intended task?
>
> Q2. Is there Jena / Protege-Owl API which reads predicates and arguments
> from the SWRL code in the owl file? Kindly provide the code snippet, if
> possible.
>
>
> Thanks for reply
>
>
> On Tue, Mar 1, 2016 at 1:33 AM, <[hidden email]>
> wrote:
>
> > Send protege-dev mailing list submissions to
> >         [hidden email]
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> > or, via email, send a message with subject or body 'help' to
> >         [hidden email]
> >
> > You can reach the person managing the list at
> >         [hidden email]
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of protege-dev digest..."
> >
> >
> > Today's Topics:
> >
> >    1. SWRL related help (lalit purohit)
> >    2. Re: SWRL related help (Martin O'Connor)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Mon, 29 Feb 2016 12:01:52 +0530
> > From: lalit purohit <[hidden email]>
> > To: [hidden email]
> > Subject: [protege-dev] SWRL related help
> > Message-ID:
> >         <CAC8ugA-7zWiymnem-WzWwuO=
> > [hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> user
> > inputs. If all user inputs and constraints (If any, like duration) are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> the
> > rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment
> > rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Check
> > city should be in country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> code?
> > A sample code, if anyone can quote to make the concept more
> understandable
> > will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/568c7969/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Mon, 29 Feb 2016 17:43:55 +0000
> > From: "Martin O'Connor" <[hidden email]>
> > To: Developer support for WebProtege and Protege Desktop
> >         <[hidden email]>
> > Subject: Re: [protege-dev] SWRL related help
> > Message-ID: <[hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> >
> > It is not clear that SWRL is suited to the type of task you outline. SWRL
> > and OWL perform monotonic inference. It seems unlikely that you want the
> > hotels that satisfy the antecedent to be reserved forever. See:
> >
> >
> >
> https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ#does-swrl-support-nonmonotonic-inference
> >
> > Martin
> >
> > On Feb 28, 2016, at 10:31 PM, lalit purohit <[hidden email]
> > <mailto:[hidden email]>> wrote:
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> > user inputs. If all user inputs and constraints (If any, like duration)
> are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> > the rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#string">Check city should be in
> > country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> > code? A sample code, if anyone can quote to make the concept more
> > understandable will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> >
> >
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]<mailto:[hidden email]>
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/d4fc8edc/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Subject: Digest Footer
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> >
> > ------------------------------
> >
> > End of protege-dev Digest, Vol 25, Issue 6
> > ******************************************
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/28233589/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Tue, 1 Mar 2016 20:40:18 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: [protege-dev] How to extract details of Axioms
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/0f27153a/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 3
> Date: Tue, 1 Mar 2016 16:52:08 +0000
> From: Matthew Horridge <[hidden email]>
> To: Developer support for WebProtege and Protege Desktop
>         <[hidden email]>
> Subject: Re: [protege-dev] How to extract details of Axioms
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> To get the SWRLRules you can just use:
>
>
> Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);
>
> What parts of the rule do you want and what do you want to do with them?
>
> You can use the getHead and getBody methods to get atoms in the head and
> body.
>
> Cheers,
>
> Matthew
>
>
> On 1 Mar 2016, at 07:10, lalit purohit <[hidden email]<mailto:
> [hidden email]>> wrote:
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> _______________________________________________
> protege-dev mailing list
> [hidden email]<mailto:[hidden email]>
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/8df10f4b/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
>
> ------------------------------
>
> End of protege-dev Digest, Vol 26, Issue 1
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160302/176e1572/attachment-0001.html>

------------------------------

Subject: Digest Footer

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


------------------------------

End of protege-dev Digest, Vol 26, Issue 2
******************************************

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


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

Re: protege-dev Digest, Vol 26, Issue 2

Gunjan Purohit
In reply to this post by lalit purohit
Thanks matthew for the reply and correction.
To make the point clear, what am I trying to do, Let me quote an example. I have an ontology for mobile phones. I want to categorize the phone as smart phone or not.

I have following SWRL rule for this (rule 'a')

mobile(?m) ^ hasAndroidOS(?m,?o) -> isSmartPhone(?m)

Now I have multiple other ontologies for mobile phone categorization with SWRL rules with them. One such ontology has swrl rule (rule 'b')

mobile(?M3125) ^ hasOS(?M3125, ?kitkat4.0) -> isSmartPhone(?M3125)

I want to create a black-box named 'compare' with following signature -

int compare (rule a, rule b)

where, 'compare' is going to return 1/2 or 3 value depending on rule 'a' and 'b' are how much close. Exact(1), 'b' is SubclassOf 'a' OR 'a' is SubClassOf 'b' (2) and DisJoint(3).  For the above quoted example, I think value '2' must be return.

I hope that the example quoted will make the point clear. Can you help me how to proceed to get the above 'compare' black box.

Thanks for anticipation


Gunjan


On Tue, Mar 8, 2016 at 3:41 AM, Matthew Horridge <[hidden email]> wrote:
Hi,

I must have mistyped the original code.  It should be:

Set<SWRLRule> rules = ont.getAxioms(AxiomType.SWRL_RULE);

It’s not clear what you mean by “compare”.  If you could provide an example that might help.


Cheers,

Matthew


On 5 Mar 2016, at 21:50, lalit purohit <[hidden email]> wrote:

Hello!!!

Can anyone please answer the question I posted earlier. I will repeat the question
---------------------------------------------------------------------------------------------------------------------------
Matthew told to get the swrl rules from the ontology using following statement,

Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

However, compiler is saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule. 

Is there already any method available to compare two swrl rules, please let me know. I am not able to get any related material for using swrlapi to compare two SWRL rules generated using protege.


Thanks
-----------------------------------------------------------------------------------------------

On Thu, Mar 3, 2016 at 1:33 AM, <[hidden email]> wrote:
Send protege-dev mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://mailman.stanford.edu/mailman/listinfo/protege-dev
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of protege-dev digest..."


Today's Topics:

   1. Re: protege-dev Digest, Vol 26, Issue 1 (lalit purohit)


----------------------------------------------------------------------

Message: 1
Date: Wed, 2 Mar 2016 10:36:00 +0530
From: lalit purohit <[hidden email]>
To: [hidden email]
Subject: Re: [protege-dev] protege-dev Digest, Vol 26, Issue 1
Message-ID:
        <CAC8ugA8q67J3aWz_+KjEeM9uDNEwAR+AzXw=[hidden email]>
Content-Type: text/plain; charset="utf-8"

Hello!!!

Thanx for the reply. For the statement
Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

you told to get the swrl rules from the ontology, however, compiler is
saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule and trying to
compare with the equivalent part of another ontology. Therefore, please
tell the correct method to get the rule and extract the head and body part
of the ontology. Or if there already any method available to compare two
swrl rules, please let me know. I am not able to get any related material
for using swrlapi to compare two SWRL rules generated using protege.


Thanks


On Wed, Mar 2, 2016 at 1:33 AM, <[hidden email]>
wrote:

> Send protege-dev mailing list submissions to
>         [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> or, via email, send a message with subject or body 'help' to
>         [hidden email]
>
> You can reach the person managing the list at
>         [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of protege-dev digest..."
>
>
> Today's Topics:
>
>    1. Re: protege-dev Digest, Vol 25, Issue 6 (lalit purohit)
>    2. How to extract details of Axioms (lalit purohit)
>    3. Re: How to extract details of Axioms (Matthew Horridge)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 1 Mar 2016 11:01:04 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: Re: [protege-dev] protege-dev Digest, Vol 25, Issue 6
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello !!
>
> It seems that the SWRL rule posted by me was wrong (due to copy-paste). The
> correct rule is -
>
>
> City(?city) ^ hasInput(?HOTEL, ?city) ^ locatedIn(?city, ?COUNTRY) ->
> Reserve(?city, ?HOTEL)
>
> Q.1  Is this rule doing the intended task?
>
> Q2. Is there Jena / Protege-Owl API which reads predicates and arguments
> from the SWRL code in the owl file? Kindly provide the code snippet, if
> possible.
>
>
> Thanks for reply
>
>
> On Tue, Mar 1, 2016 at 1:33 AM, <[hidden email]>
> wrote:
>
> > Send protege-dev mailing list submissions to
> >         [hidden email]
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> > or, via email, send a message with subject or body 'help' to
> >         [hidden email]
> >
> > You can reach the person managing the list at
> >         [hidden email]
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of protege-dev digest..."
> >
> >
> > Today's Topics:
> >
> >    1. SWRL related help (lalit purohit)
> >    2. Re: SWRL related help (Martin O'Connor)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Mon, 29 Feb 2016 12:01:52 +0530
> > From: lalit purohit <[hidden email]>
> > To: [hidden email]
> > Subject: [protege-dev] SWRL related help
> > Message-ID:
> >         <CAC8ugA-7zWiymnem-WzWwuO=
> > [hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> user
> > inputs. If all user inputs and constraints (If any, like duration) are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> the
> > rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment
> > rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Check
> > city should be in country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> code?
> > A sample code, if anyone can quote to make the concept more
> understandable
> > will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/568c7969/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Mon, 29 Feb 2016 17:43:55 +0000
> > From: "Martin O'Connor" <[hidden email]>
> > To: Developer support for WebProtege and Protege Desktop
> >         <[hidden email]>
> > Subject: Re: [protege-dev] SWRL related help
> > Message-ID: <[hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> >
> > It is not clear that SWRL is suited to the type of task you outline. SWRL
> > and OWL perform monotonic inference. It seems unlikely that you want the
> > hotels that satisfy the antecedent to be reserved forever. See:
> >
> >
> >
> https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ#does-swrl-support-nonmonotonic-inference
> >
> > Martin
> >
> > On Feb 28, 2016, at 10:31 PM, lalit purohit <[hidden email]
> > <mailto:[hidden email]>> wrote:
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> > user inputs. If all user inputs and constraints (If any, like duration)
> are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> > the rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#string">Check city should be in
> > country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> > code? A sample code, if anyone can quote to make the concept more
> > understandable will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> >
> >
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]<mailto:[hidden email]>
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/d4fc8edc/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Subject: Digest Footer
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> >
> > ------------------------------
> >
> > End of protege-dev Digest, Vol 25, Issue 6
> > ******************************************
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/28233589/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Tue, 1 Mar 2016 20:40:18 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: [protege-dev] How to extract details of Axioms
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/0f27153a/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 3
> Date: Tue, 1 Mar 2016 16:52:08 +0000
> From: Matthew Horridge <[hidden email]>
> To: Developer support for WebProtege and Protege Desktop
>         <[hidden email]>
> Subject: Re: [protege-dev] How to extract details of Axioms
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> To get the SWRLRules you can just use:
>
>
> Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);
>
> What parts of the rule do you want and what do you want to do with them?
>
> You can use the getHead and getBody methods to get atoms in the head and
> body.
>
> Cheers,
>
> Matthew
>
>
> On 1 Mar 2016, at 07:10, lalit purohit <[hidden email]<mailto:
> [hidden email]>> wrote:
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> _______________________________________________
> protege-dev mailing list
> [hidden email]<mailto:[hidden email]>
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/8df10f4b/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
>
> ------------------------------
>
> End of protege-dev Digest, Vol 26, Issue 1
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160302/176e1572/attachment-0001.html>

------------------------------

Subject: Digest Footer

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


------------------------------

End of protege-dev Digest, Vol 26, Issue 2
******************************************

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


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



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

Re: protege-dev Digest, Vol 26, Issue 2

Lorenz Buehmann
In reply to this post by Matthew Horridge-2
There is no method for comparing SWRL rules. The whole implementation would depend on the relations that you define between two rules.

Hi,

I must have mistyped the original code.  It should be:

Set<SWRLRule> rules = ont.getAxioms(AxiomType.SWRL_RULE);

It’s not clear what you mean by “compare”.  If you could provide an example that might help.


Cheers,

Matthew


On 5 Mar 2016, at 21:50, lalit purohit <[hidden email]> wrote:

Hello!!!

Can anyone please answer the question I posted earlier. I will repeat the question
---------------------------------------------------------------------------------------------------------------------------
Matthew told to get the swrl rules from the ontology using following statement,

Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

However, compiler is saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule. 

Is there already any method available to compare two swrl rules, please let me know. I am not able to get any related material for using swrlapi to compare two SWRL rules generated using protege.


Thanks
-----------------------------------------------------------------------------------------------

On Thu, Mar 3, 2016 at 1:33 AM, <[hidden email]> wrote:
Send protege-dev mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://mailman.stanford.edu/mailman/listinfo/protege-dev
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of protege-dev digest..."


Today's Topics:

   1. Re: protege-dev Digest, Vol 26, Issue 1 (lalit purohit)


----------------------------------------------------------------------

Message: 1
Date: Wed, 2 Mar 2016 10:36:00 +0530
From: lalit purohit <[hidden email]>
To: [hidden email]
Subject: Re: [protege-dev] protege-dev Digest, Vol 26, Issue 1
Message-ID:
        <CAC8ugA8q67J3aWz_+KjEeM9uDNEwAR+AzXw=[hidden email]>
Content-Type: text/plain; charset="utf-8"

Hello!!!

Thanx for the reply. For the statement
Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

you told to get the swrl rules from the ontology, however, compiler is
saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule and trying to
compare with the equivalent part of another ontology. Therefore, please
tell the correct method to get the rule and extract the head and body part
of the ontology. Or if there already any method available to compare two
swrl rules, please let me know. I am not able to get any related material
for using swrlapi to compare two SWRL rules generated using protege.


Thanks


On Wed, Mar 2, 2016 at 1:33 AM, <[hidden email]>
wrote:

> Send protege-dev mailing list submissions to
>         [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> or, via email, send a message with subject or body 'help' to
>         [hidden email]
>
> You can reach the person managing the list at
>         [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of protege-dev digest..."
>
>
> Today's Topics:
>
>    1. Re: protege-dev Digest, Vol 25, Issue 6 (lalit purohit)
>    2. How to extract details of Axioms (lalit purohit)
>    3. Re: How to extract details of Axioms (Matthew Horridge)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 1 Mar 2016 11:01:04 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: Re: [protege-dev] protege-dev Digest, Vol 25, Issue 6
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello !!
>
> It seems that the SWRL rule posted by me was wrong (due to copy-paste). The
> correct rule is -
>
>
> City(?city) ^ hasInput(?HOTEL, ?city) ^ locatedIn(?city, ?COUNTRY) ->
> Reserve(?city, ?HOTEL)
>
> Q.1  Is this rule doing the intended task?
>
> Q2. Is there Jena / Protege-Owl API which reads predicates and arguments
> from the SWRL code in the owl file? Kindly provide the code snippet, if
> possible.
>
>
> Thanks for reply
>
>
> On Tue, Mar 1, 2016 at 1:33 AM, <[hidden email]>
> wrote:
>
> > Send protege-dev mailing list submissions to
> >         [hidden email]
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> > or, via email, send a message with subject or body 'help' to
> >         [hidden email]
> >
> > You can reach the person managing the list at
> >         [hidden email]
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of protege-dev digest..."
> >
> >
> > Today's Topics:
> >
> >    1. SWRL related help (lalit purohit)
> >    2. Re: SWRL related help (Martin O'Connor)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Mon, 29 Feb 2016 12:01:52 +0530
> > From: lalit purohit <[hidden email]>
> > To: [hidden email]
> > Subject: [protege-dev] SWRL related help
> > Message-ID:
> >         <CAC8ugA-7zWiymnem-WzWwuO=
> > [hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> user
> > inputs. If all user inputs and constraints (If any, like duration) are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> the
> > rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment
> > rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Check
> > city should be in country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> code?
> > A sample code, if anyone can quote to make the concept more
> understandable
> > will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/568c7969/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Mon, 29 Feb 2016 17:43:55 +0000
> > From: "Martin O'Connor" <[hidden email]>
> > To: Developer support for WebProtege and Protege Desktop
> >         <[hidden email]>
> > Subject: Re: [protege-dev] SWRL related help
> > Message-ID: <[hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> >
> > It is not clear that SWRL is suited to the type of task you outline. SWRL
> > and OWL perform monotonic inference. It seems unlikely that you want the
> > hotels that satisfy the antecedent to be reserved forever. See:
> >
> >
> >
> https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ#does-swrl-support-nonmonotonic-inference
> >
> > Martin
> >
> > On Feb 28, 2016, at 10:31 PM, lalit purohit <[hidden email]
> > <mailto:[hidden email]>> wrote:
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> > user inputs. If all user inputs and constraints (If any, like duration)
> are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> > the rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#string">Check city should be in
> > country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> > code? A sample code, if anyone can quote to make the concept more
> > understandable will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> >
> >
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]<mailto:[hidden email]>
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/d4fc8edc/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Subject: Digest Footer
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> >
> > ------------------------------
> >
> > End of protege-dev Digest, Vol 25, Issue 6
> > ******************************************
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/28233589/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Tue, 1 Mar 2016 20:40:18 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: [protege-dev] How to extract details of Axioms
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/0f27153a/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 3
> Date: Tue, 1 Mar 2016 16:52:08 +0000
> From: Matthew Horridge <[hidden email]>
> To: Developer support for WebProtege and Protege Desktop
>         <[hidden email]>
> Subject: Re: [protege-dev] How to extract details of Axioms
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> To get the SWRLRules you can just use:
>
>
> Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);
>
> What parts of the rule do you want and what do you want to do with them?
>
> You can use the getHead and getBody methods to get atoms in the head and
> body.
>
> Cheers,
>
> Matthew
>
>
> On 1 Mar 2016, at 07:10, lalit purohit <[hidden email]<mailto:
> [hidden email]>> wrote:
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> _______________________________________________
> protege-dev mailing list
> [hidden email]<mailto:[hidden email]>
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/8df10f4b/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
>
> ------------------------------
>
> End of protege-dev Digest, Vol 26, Issue 1
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160302/176e1572/attachment-0001.html>

------------------------------

Subject: Digest Footer

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


------------------------------

End of protege-dev Digest, Vol 26, Issue 2
******************************************

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



_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

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

Re: protege-dev Digest, Vol 26, Issue 2

Lorenz Buehmann
In reply to this post by Gunjan Purohit
I'm wondering why you and your colleague are both asking for the same thing. As I already said, there is no implementation for comparing two SWRL rules. It's your turn to compare body and head of both rules, i.e. compare atoms of die bodies and heads. All of this you have to define first, and then you can start implementing.

Lorenz
Thanks matthew for the reply and correction.
To make the point clear, what am I trying to do, Let me quote an example. I have an ontology for mobile phones. I want to categorize the phone as smart phone or not.

I have following SWRL rule for this (rule 'a')

mobile(?m) ^ hasAndroidOS(?m,?o) -> isSmartPhone(?m)

Now I have multiple other ontologies for mobile phone categorization with SWRL rules with them. One such ontology has swrl rule (rule 'b')

mobile(?M3125) ^ hasOS(?M3125, ?kitkat4.0) -> isSmartPhone(?M3125)

I want to create a black-box named 'compare' with following signature -

int compare (rule a, rule b)

where, 'compare' is going to return 1/2 or 3 value depending on rule 'a' and 'b' are how much close. Exact(1), 'b' is SubclassOf 'a' OR 'a' is SubClassOf 'b' (2) and DisJoint(3).  For the above quoted example, I think value '2' must be return.

I hope that the example quoted will make the point clear. Can you help me how to proceed to get the above 'compare' black box.

Thanks for anticipation


Gunjan


On Tue, Mar 8, 2016 at 3:41 AM, Matthew Horridge <[hidden email]> wrote:
Hi,

I must have mistyped the original code.  It should be:

Set<SWRLRule> rules = ont.getAxioms(AxiomType.SWRL_RULE);

It’s not clear what you mean by “compare”.  If you could provide an example that might help.


Cheers,

Matthew


On 5 Mar 2016, at 21:50, lalit purohit <[hidden email]> wrote:

Hello!!!

Can anyone please answer the question I posted earlier. I will repeat the question
---------------------------------------------------------------------------------------------------------------------------
Matthew told to get the swrl rules from the ontology using following statement,

Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

However, compiler is saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule. 

Is there already any method available to compare two swrl rules, please let me know. I am not able to get any related material for using swrlapi to compare two SWRL rules generated using protege.


Thanks
-----------------------------------------------------------------------------------------------

On Thu, Mar 3, 2016 at 1:33 AM, <[hidden email]> wrote:
Send protege-dev mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://mailman.stanford.edu/mailman/listinfo/protege-dev
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of protege-dev digest..."


Today's Topics:

   1. Re: protege-dev Digest, Vol 26, Issue 1 (lalit purohit)


----------------------------------------------------------------------

Message: 1
Date: Wed, 2 Mar 2016 10:36:00 +0530
From: lalit purohit <[hidden email]>
To: [hidden email]
Subject: Re: [protege-dev] protege-dev Digest, Vol 26, Issue 1
Message-ID:
        <CAC8ugA8q67J3aWz_+KjEeM9uDNEwAR+AzXw=[hidden email]>
Content-Type: text/plain; charset="utf-8"

Hello!!!

Thanx for the reply. For the statement
Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

you told to get the swrl rules from the ontology, however, compiler is
saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule and trying to
compare with the equivalent part of another ontology. Therefore, please
tell the correct method to get the rule and extract the head and body part
of the ontology. Or if there already any method available to compare two
swrl rules, please let me know. I am not able to get any related material
for using swrlapi to compare two SWRL rules generated using protege.


Thanks


On Wed, Mar 2, 2016 at 1:33 AM, <[hidden email]>
wrote:

> Send protege-dev mailing list submissions to
>         [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> or, via email, send a message with subject or body 'help' to
>         [hidden email]
>
> You can reach the person managing the list at
>         [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of protege-dev digest..."
>
>
> Today's Topics:
>
>    1. Re: protege-dev Digest, Vol 25, Issue 6 (lalit purohit)
>    2. How to extract details of Axioms (lalit purohit)
>    3. Re: How to extract details of Axioms (Matthew Horridge)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 1 Mar 2016 11:01:04 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: Re: [protege-dev] protege-dev Digest, Vol 25, Issue 6
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello !!
>
> It seems that the SWRL rule posted by me was wrong (due to copy-paste). The
> correct rule is -
>
>
> City(?city) ^ hasInput(?HOTEL, ?city) ^ locatedIn(?city, ?COUNTRY) ->
> Reserve(?city, ?HOTEL)
>
> Q.1  Is this rule doing the intended task?
>
> Q2. Is there Jena / Protege-Owl API which reads predicates and arguments
> from the SWRL code in the owl file? Kindly provide the code snippet, if
> possible.
>
>
> Thanks for reply
>
>
> On Tue, Mar 1, 2016 at 1:33 AM, <[hidden email]>
> wrote:
>
> > Send protege-dev mailing list submissions to
> >         [hidden email]
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> > or, via email, send a message with subject or body 'help' to
> >         [hidden email]
> >
> > You can reach the person managing the list at
> >         [hidden email]
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of protege-dev digest..."
> >
> >
> > Today's Topics:
> >
> >    1. SWRL related help (lalit purohit)
> >    2. Re: SWRL related help (Martin O'Connor)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Mon, 29 Feb 2016 12:01:52 +0530
> > From: lalit purohit <[hidden email]>
> > To: [hidden email]
> > Subject: [protege-dev] SWRL related help
> > Message-ID:
> >         <CAC8ugA-7zWiymnem-WzWwuO=
> > [hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> user
> > inputs. If all user inputs and constraints (If any, like duration) are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> the
> > rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment
> > rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Check
> > city should be in country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> code?
> > A sample code, if anyone can quote to make the concept more
> understandable
> > will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/568c7969/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Mon, 29 Feb 2016 17:43:55 +0000
> > From: "Martin O'Connor" <[hidden email]>
> > To: Developer support for WebProtege and Protege Desktop
> >         <[hidden email]>
> > Subject: Re: [protege-dev] SWRL related help
> > Message-ID: <[hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> >
> > It is not clear that SWRL is suited to the type of task you outline. SWRL
> > and OWL perform monotonic inference. It seems unlikely that you want the
> > hotels that satisfy the antecedent to be reserved forever. See:
> >
> >
> >
> https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ#does-swrl-support-nonmonotonic-inference
> >
> > Martin
> >
> > On Feb 28, 2016, at 10:31 PM, lalit purohit <[hidden email]
> > <mailto:[hidden email]>> wrote:
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> > user inputs. If all user inputs and constraints (If any, like duration)
> are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> > the rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#string">Check city should be in
> > country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> > code? A sample code, if anyone can quote to make the concept more
> > understandable will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> >
> >
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]<mailto:[hidden email]>
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/d4fc8edc/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Subject: Digest Footer
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> >
> > ------------------------------
> >
> > End of protege-dev Digest, Vol 25, Issue 6
> > ******************************************
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/28233589/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Tue, 1 Mar 2016 20:40:18 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: [protege-dev] How to extract details of Axioms
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/0f27153a/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 3
> Date: Tue, 1 Mar 2016 16:52:08 +0000
> From: Matthew Horridge <[hidden email]>
> To: Developer support for WebProtege and Protege Desktop
>         <[hidden email]>
> Subject: Re: [protege-dev] How to extract details of Axioms
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> To get the SWRLRules you can just use:
>
>
> Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);
>
> What parts of the rule do you want and what do you want to do with them?
>
> You can use the getHead and getBody methods to get atoms in the head and
> body.
>
> Cheers,
>
> Matthew
>
>
> On 1 Mar 2016, at 07:10, lalit purohit <[hidden email]<mailto:
> [hidden email]>> wrote:
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> _______________________________________________
> protege-dev mailing list
> [hidden email]<mailto:[hidden email]>
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/8df10f4b/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
>
> ------------------------------
>
> End of protege-dev Digest, Vol 26, Issue 1
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160302/176e1572/attachment-0001.html>

------------------------------

Subject: Digest Footer

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


------------------------------

End of protege-dev Digest, Vol 26, Issue 2
******************************************

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


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




_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

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

Re: protege-dev Digest, Vol 26, Issue 2

Gunjan Purohit
In reply to this post by Lorenz Buehmann
OK Sir,

Thank you very much for your time.




On Tue, Mar 8, 2016 at 2:57 PM, Lorenz B. <[hidden email]> wrote:
There is no method for comparing SWRL rules. The whole implementation would depend on the relations that you define between two rules.

Hi,

I must have mistyped the original code.  It should be:

Set<SWRLRule> rules = ont.getAxioms(AxiomType.SWRL_RULE);

It’s not clear what you mean by “compare”.  If you could provide an example that might help.


Cheers,

Matthew


On 5 Mar 2016, at 21:50, lalit purohit <[hidden email]> wrote:

Hello!!!

Can anyone please answer the question I posted earlier. I will repeat the question
---------------------------------------------------------------------------------------------------------------------------
Matthew told to get the swrl rules from the ontology using following statement,

Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

However, compiler is saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule. 

Is there already any method available to compare two swrl rules, please let me know. I am not able to get any related material for using swrlapi to compare two SWRL rules generated using protege.


Thanks
-----------------------------------------------------------------------------------------------

On Thu, Mar 3, 2016 at 1:33 AM, <[hidden email]> wrote:
Send protege-dev mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://mailman.stanford.edu/mailman/listinfo/protege-dev
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of protege-dev digest..."


Today's Topics:

   1. Re: protege-dev Digest, Vol 26, Issue 1 (lalit purohit)


----------------------------------------------------------------------

Message: 1
Date: Wed, 2 Mar 2016 10:36:00 +0530
From: lalit purohit <[hidden email]>
To: [hidden email]
Subject: Re: [protege-dev] protege-dev Digest, Vol 26, Issue 1
Message-ID:
        <CAC8ugA8q67J3aWz_+KjEeM9uDNEwAR+AzXw=[hidden email]>
Content-Type: text/plain; charset="utf-8"

Hello!!!

Thanx for the reply. For the statement
Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);

you told to get the swrl rules from the ontology, however, compiler is
saying that change type of rules variable to int, as getAxiomCount() method
must return int not the rule. I am using swrlapi-1.0.0.-bita-18.jar.

With the code I am extracting head and body part of swrl rule and trying to
compare with the equivalent part of another ontology. Therefore, please
tell the correct method to get the rule and extract the head and body part
of the ontology. Or if there already any method available to compare two
swrl rules, please let me know. I am not able to get any related material
for using swrlapi to compare two SWRL rules generated using protege.


Thanks


On Wed, Mar 2, 2016 at 1:33 AM, <[hidden email]>
wrote:

> Send protege-dev mailing list submissions to
>         [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> or, via email, send a message with subject or body 'help' to
>         [hidden email]
>
> You can reach the person managing the list at
>         [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of protege-dev digest..."
>
>
> Today's Topics:
>
>    1. Re: protege-dev Digest, Vol 25, Issue 6 (lalit purohit)
>    2. How to extract details of Axioms (lalit purohit)
>    3. Re: How to extract details of Axioms (Matthew Horridge)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 1 Mar 2016 11:01:04 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: Re: [protege-dev] protege-dev Digest, Vol 25, Issue 6
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello !!
>
> It seems that the SWRL rule posted by me was wrong (due to copy-paste). The
> correct rule is -
>
>
> City(?city) ^ hasInput(?HOTEL, ?city) ^ locatedIn(?city, ?COUNTRY) ->
> Reserve(?city, ?HOTEL)
>
> Q.1  Is this rule doing the intended task?
>
> Q2. Is there Jena / Protege-Owl API which reads predicates and arguments
> from the SWRL code in the owl file? Kindly provide the code snippet, if
> possible.
>
>
> Thanks for reply
>
>
> On Tue, Mar 1, 2016 at 1:33 AM, <[hidden email]>
> wrote:
>
> > Send protege-dev mailing list submissions to
> >         [hidden email]
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         https://mailman.stanford.edu/mailman/listinfo/protege-dev
> > or, via email, send a message with subject or body 'help' to
> >         [hidden email]
> >
> > You can reach the person managing the list at
> >         [hidden email]
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of protege-dev digest..."
> >
> >
> > Today's Topics:
> >
> >    1. SWRL related help (lalit purohit)
> >    2. Re: SWRL related help (Martin O'Connor)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Mon, 29 Feb 2016 12:01:52 +0530
> > From: lalit purohit <[hidden email]>
> > To: [hidden email]
> > Subject: [protege-dev] SWRL related help
> > Message-ID:
> >         <CAC8ugA-7zWiymnem-WzWwuO=
> > [hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> user
> > inputs. If all user inputs and constraints (If any, like duration) are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> the
> > rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment
> > rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Check
> > city should be in country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> code?
> > A sample code, if anyone can quote to make the concept more
> understandable
> > will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/568c7969/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Mon, 29 Feb 2016 17:43:55 +0000
> > From: "Martin O'Connor" <[hidden email]>
> > To: Developer support for WebProtege and Protege Desktop
> >         <[hidden email]>
> > Subject: Re: [protege-dev] SWRL related help
> > Message-ID: <[hidden email]>
> > Content-Type: text/plain; charset="utf-8"
> >
> >
> > It is not clear that SWRL is suited to the type of task you outline. SWRL
> > and OWL perform monotonic inference. It seems unlikely that you want the
> > hotels that satisfy the antecedent to be reserved forever. See:
> >
> >
> >
> https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ#does-swrl-support-nonmonotonic-inference
> >
> > Martin
> >
> > On Feb 28, 2016, at 10:31 PM, lalit purohit <[hidden email]
> > <mailto:[hidden email]>> wrote:
> >
> > Hello!!
> >
> > I am new to SWRL and protege. I am using SWRL tab in protege 5.0.0 (Build
> > bita 23). I need to write SWRL rule for the following case:
> >
> > I need to reserve a hotel in a city. The hotel database is checked for
> > user inputs. If all user inputs and constraints (If any, like duration)
> are
> > satisfied and if hotel is available, the hotel is booked. The situation
> is
> > modeled as four thing
> > i) Input (Country, City, Duration of booking, other booking details)
> > ii) Output (Summary of hotel booking confirmation)
> > iii) Precondition (City in which hotel is to be booked, must be in the
> > country)
> > iv) Effect (Hotel is booked)
> >
> > For the above situation, I have written rule to take care of Precondition
> > and effect as follows
> >
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------
> > City(?city) ? hasInput(?HOTEL, ?city) ? locatedIn(?city, ?COUNTRY) ?
> > isReserved(?city, ?HOTEL)
> >
> > Q.1 Does this code takes care of point iii (as antecedent, left side of
> > the rule) and iv (the consequent, the right side of the rule)
> >
> >
> -----------------------------------------------------------------------------------------------------------------------------------
> >
> > The corresponding code generated by protege is as follows :
> >
> >
> > <rdf:Description rdf:about="city">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="HOTEL">
> >        <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> > <rdf:Description rdf:about="COUNTRY">
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable
> "/>
> > </rdf:Description>
> >
> > <rdf:Description>
> >         <swrla:isRuleEnabled rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#boolean">true</swrla:isRuleEnabled>
> >         <rdfs:comment rdf:datatype="
> > http://www.w3.org/2001/XMLSchema#string">Check city should be in
> > country</rdfs:comment>
> >         <rdfs:label rdf:datatype="
> http://www.w3.org/2001/XMLSchema#string
> > ">CityBelongsToCountry</rdfs:label>
> >         <rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
> >         <swrl:body>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#ClassAtom"/>
> >                         <swrl:classPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#City"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                         <rdf:first>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                 <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/Profile.owl#hasInput"/>
> >                                 <swrl:argument1 rdf:resource="HOTEL"/>
> >                                 <swrl:argument2 rdf:resource="city"/>
> >                             </rdf:Description>
> >                         </rdf:first>
> >                         <rdf:rest>
> >                             <rdf:Description>
> >                                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                                 <rdf:first>
> >                                     <rdf:Description>
> >                                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                                         <swrl:propertyPredicate
> > rdf:resource="http://127.0.0.1/ontology/protont.owl#locatedIn"/>
> >                                         <swrl:argument1
> > rdf:resource="city"/>
> >                                         <swrl:argument2
> > rdf:resource="COUNTRY"/>
> >                                     </rdf:Description>
> >                                 </rdf:first>
> >                                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >                             </rdf:Description>
> >                         </rdf:rest>
> >                     </rdf:Description>
> >                 </rdf:rest>
> >             </rdf:Description>
> >         </swrl:body>
> >         <swrl:head>
> >             <rdf:Description>
> >                 <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#AtomList"/>
> >                 <rdf:first>
> >                     <rdf:Description>
> >                         <rdf:type rdf:resource="
> > http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
> >                         <swrl:propertyPredicate rdf:resource="
> > http://127.0.0.1/ontology/travel.owl#isReserved"/>
> >                         <swrl:argument1 rdf:resource="city"/>
> >                         <swrl:argument2 rdf:resource="HOTEL"/>
> >                     </rdf:Description>
> >                 </rdf:first>
> >                 <rdf:rest rdf:resource="
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
> >             </rdf:Description>
> >         </swrl:head>
> >     </rdf:Description>
> > </rdf:RDF>
> >
> >
> > Q.2: Can I use Jena API to extract Predicates and Arguments from this
> > code? A sample code, if anyone can quote to make the concept more
> > understandable will be very helpful
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------------
> >
> > Thanks
> >
> >
> > Lalit Purohit
> >
> >
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]<mailto:[hidden email]>
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160229/d4fc8edc/attachment-0001.html
> > >
> >
> > ------------------------------
> >
> > Subject: Digest Footer
> >
> > _______________________________________________
> > protege-dev mailing list
> > [hidden email]
> > https://mailman.stanford.edu/mailman/listinfo/protege-dev
> >
> >
> > ------------------------------
> >
> > End of protege-dev Digest, Vol 25, Issue 6
> > ******************************************
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/28233589/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Tue, 1 Mar 2016 20:40:18 +0530
> From: lalit purohit <[hidden email]>
> To: [hidden email]
> Subject: [protege-dev] How to extract details of Axioms
> Message-ID:
>         <
> [hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/0f27153a/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 3
> Date: Tue, 1 Mar 2016 16:52:08 +0000
> From: Matthew Horridge <[hidden email]>
> To: Developer support for WebProtege and Protege Desktop
>         <[hidden email]>
> Subject: Re: [protege-dev] How to extract details of Axioms
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> To get the SWRLRules you can just use:
>
>
> Set<SWRLRule> rules = ont.getAxiomCount(AxiomType.SWRL_RULE);
>
> What parts of the rule do you want and what do you want to do with them?
>
> You can use the getHead and getBody methods to get atoms in the head and
> body.
>
> Cheers,
>
> Matthew
>
>
> On 1 Mar 2016, at 07:10, lalit purohit <[hidden email]<mailto:
> [hidden email]>> wrote:
>
> Hello!!!
>
> I have read the ontology and trying to extract the details of axioms using
> swrlapi 1.0.0-18. How to get individual parts of axioms?  Following is the
> code i have written -
>
>
> -------------------------------------------------------------------------------
>
>  OWLOntologyManager ontologyManager =
> OWLManager.createOWLOntologyManager();
>     OWLOntology ontology  =
> ontologyManager.loadOntologyFromOntologyDocument(new File(inputFileName));
>
>
>     System.out.println("\n\nPrinting axioms in first ontology: ");
>
>     Set<OWLAxiom> axioms = ontology.getAxioms();
>     for (OWLAxiom axiom : axioms) {
>         if(axiom instanceof SWRLRule) // Print only axiom which are
> SWRLRules
>         {
>         System.out.print("Ontology axiom: " + axiom);
>
>         Set<OWLClass> oc = axiom.getClassesInSignature();
>         for(OWLClass owl_class : oc)
>         {
>          System.out.println("\n OWLClass :: "+owl_class);
>         }
>         System.out.print("\n");
>         }
>      }
>
>
> ---------------------------------------------------------------------------------------
>
> Answer on screen is :
>
> Ontology axiom: DLSafeRule( Body(ClassAtom(<
> http://127.0.0.1/ontology/findHospital.owl#Hospital> Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/Profile.owl#hasInput> Variable(<
> http://127.0.0.1/services/1.1/Bed>) Variable(<
> http://127.0.0.1/services/1.1/hospital>)) ObjectPropertyAtom(<
> http://127.0.0.1/ontology/protont.owl#available> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/City>))) Head(ObjectPropertyAtom(<
> http://127.0.0.1/ontology/findHospital.owl#isReserved> Variable(<
> http://127.0.0.1/services/1.1/Hospital>) Variable(<
> http://127.0.0.1/services/1.1/Bed>))) )
>
>  OWLClass ::  <http://127.0.0.1/ontology/findHospital.owl#Hospital>
>
>
> ------------------------------------------------------------------------------------------
>
> Question - How can I get individual parts of axiom i.e. Body,
> ObjectPropertyAtom in Body, and Variables in ObjectPropertyAtom , Head and
> variables in Head using swrlapi. The SWRL code is generated manually using
> protege.
>
>
> Thanx
> _______________________________________________
> protege-dev mailing list
> [hidden email]<mailto:[hidden email]>
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160301/8df10f4b/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev
>
>
> ------------------------------
>
> End of protege-dev Digest, Vol 26, Issue 1
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-dev/attachments/20160302/176e1572/attachment-0001.html>

------------------------------

Subject: Digest Footer

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


------------------------------

End of protege-dev Digest, Vol 26, Issue 2
******************************************

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



_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

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



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

Re: protege-dev Digest, Vol 26, Issue 2

Matthew Horridge-2
Administrator
Further to what Lorenz has said, you also don’t need SWRL to represent your domain knowledge.  It can be represented in plain OWL.

You can just define a class SmartPhone and make it equivalent to 

Phone and hasOS some SmartPhoneOS

and also,

make M3125 a subclass of 

Phone and hasOS some KitKat4.0

also KitKat4.0 should be a subclass of AndroidOS and AndroidOS should a subclass of SmartPhoneOS (note I’m assuming that an instance of an operating system is the one installed on an individual phone.  

When you run the reasoner, M3215 will be inferred to be a subclass of SmartPhone.

I’ve attached a small ontology for you to take a look at.  Also see the screenshot below.

Cheers,

Matthew


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

phones.owl (6K) Download Attachment
ATT00001.htm (428 bytes) Download Attachment
PastedGraphic-1.png (95K) Download Attachment
ATT00002.htm (125K) Download Attachment