text to swrl

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

text to swrl

bilel
hi; 
please i need to convert a text written in english to swrl rules. each line contain if..then. 
i need to convert each line to swrl automatically to enrich my ontology

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

Re: text to swrl

Michael DeBellis-2
To my knowledge there is no tool that just converts text to SWRL rules. IMO you don't really need such a tool because once you understand the semantics of SWRL rules the mapping from axioms about your ontology to SWRL rules is so straight forward. I wrote a short SWRL tutorial that can be found here: https://symbolicshacker.blogspot.com/2017/06/swrl-process-modeling-tutorial.html  

Martin's presentation on SWRL is also excellent and something I think every new user should look through carefully. Especially for understanding things like the Open World Assumption and the lack of support for negation as failure which are different than most other rule systems: https://protege.stanford.edu/conference/2009/slides/SWRL2009ProtegeConference.pdf  

The documentation for the SWRLTab can be found here: https://github.com/protegeproject/swrlapi/wiki  

There are also other links in my tutorial. 

The basics of a SWRL rule are that the only connector is "^" (and). Also, every parameter must start with a question mark and all parameters on the left side are implicitly universally quantified and all on the right are implicitly existentially quantified. Also, class queries (left side) or assertions (right side) are treated as unary predicates and object properties as binary predicates. 

So if Human and Mortal are both classes the rule: 

Human(?x) -> Mortal(?x)    says that all Humans are Mortal. So if there was an individual named Socrates who was a Human but not a Mortal this rule would bind to Socrates on the left side and then assert that Socrates was also an instance of the Mortal class on the right side. 

Or if hasParent is an object property and hasBrother is an object property and hasUncle is an object property then the rule: 

hasParent(?x, ?y) ^ hasBrother(?y, ?z) -> hasUncle(?x, ?z)

Asserts that for all x if x has a parent and that parent has a brother then that brother is an uncle for x. 

One bit of advice: make sure you run the reasoner after every rule and check each rule to make sure it's doing what you expect it to before writing more. You probably would do that anyway but I've seen at least one new user get into a situation that was very hard to debug because they wrote over 20 rules and then tried to debug them. 

Michael

On Fri, Apr 19, 2019 at 1:48 AM Bilel Abderrahman <[hidden email]> wrote:
hi; 
please i need to convert a text written in english to swrl rules. each line contain if..then. 
i need to convert each line to swrl automatically to enrich my ontology
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user

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

Re: text to swrl

bilel
thank you mr michael; your tutorial is very interesting.
I will follow your instructions.
i will use nlp and similarity measures to search appropriate concepts and if i don't found concepts or object propriety i should add it to ontology to enrich it.

Le ven. 19 avr. 2019 à 15:00, Michael DeBellis <[hidden email]> a écrit :
To my knowledge there is no tool that just converts text to SWRL rules. IMO you don't really need such a tool because once you understand the semantics of SWRL rules the mapping from axioms about your ontology to SWRL rules is so straight forward. I wrote a short SWRL tutorial that can be found here: https://symbolicshacker.blogspot.com/2017/06/swrl-process-modeling-tutorial.html  

Martin's presentation on SWRL is also excellent and something I think every new user should look through carefully. Especially for understanding things like the Open World Assumption and the lack of support for negation as failure which are different than most other rule systems: https://protege.stanford.edu/conference/2009/slides/SWRL2009ProtegeConference.pdf  

The documentation for the SWRLTab can be found here: https://github.com/protegeproject/swrlapi/wiki  

There are also other links in my tutorial. 

The basics of a SWRL rule are that the only connector is "^" (and). Also, every parameter must start with a question mark and all parameters on the left side are implicitly universally quantified and all on the right are implicitly existentially quantified. Also, class queries (left side) or assertions (right side) are treated as unary predicates and object properties as binary predicates. 

So if Human and Mortal are both classes the rule: 

Human(?x) -> Mortal(?x)    says that all Humans are Mortal. So if there was an individual named Socrates who was a Human but not a Mortal this rule would bind to Socrates on the left side and then assert that Socrates was also an instance of the Mortal class on the right side. 

Or if hasParent is an object property and hasBrother is an object property and hasUncle is an object property then the rule: 

hasParent(?x, ?y) ^ hasBrother(?y, ?z) -> hasUncle(?x, ?z)

Asserts that for all x if x has a parent and that parent has a brother then that brother is an uncle for x. 

One bit of advice: make sure you run the reasoner after every rule and check each rule to make sure it's doing what you expect it to before writing more. You probably would do that anyway but I've seen at least one new user get into a situation that was very hard to debug because they wrote over 20 rules and then tried to debug them. 

Michael

On Fri, Apr 19, 2019 at 1:48 AM Bilel Abderrahman <[hidden email]> wrote:
hi; 
please i need to convert a text written in english to swrl rules. each line contain if..then. 
i need to convert each line to swrl automatically to enrich my ontology
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user

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

Re: text to swrl

bilel
In reply to this post by Michael DeBellis-2
think you
you can give an example of algorithm or code java ?

Le ven. 19 avr. 2019 à 16:00, Michael DeBellis <[hidden email]> a écrit :
To my knowledge there is no tool that just converts text to SWRL rules. IMO you don't really need such a tool because once you understand the semantics of SWRL rules the mapping from axioms about your ontology to SWRL rules is so straight forward. I wrote a short SWRL tutorial that can be found here: https://symbolicshacker.blogspot.com/2017/06/swrl-process-modeling-tutorial.html  

Martin's presentation on SWRL is also excellent and something I think every new user should look through carefully. Especially for understanding things like the Open World Assumption and the lack of support for negation as failure which are different than most other rule systems: https://protege.stanford.edu/conference/2009/slides/SWRL2009ProtegeConference.pdf  

The documentation for the SWRLTab can be found here: https://github.com/protegeproject/swrlapi/wiki  

There are also other links in my tutorial. 

The basics of a SWRL rule are that the only connector is "^" (and). Also, every parameter must start with a question mark and all parameters on the left side are implicitly universally quantified and all on the right are implicitly existentially quantified. Also, class queries (left side) or assertions (right side) are treated as unary predicates and object properties as binary predicates. 

So if Human and Mortal are both classes the rule: 

Human(?x) -> Mortal(?x)    says that all Humans are Mortal. So if there was an individual named Socrates who was a Human but not a Mortal this rule would bind to Socrates on the left side and then assert that Socrates was also an instance of the Mortal class on the right side. 

Or if hasParent is an object property and hasBrother is an object property and hasUncle is an object property then the rule: 

hasParent(?x, ?y) ^ hasBrother(?y, ?z) -> hasUncle(?x, ?z)

Asserts that for all x if x has a parent and that parent has a brother then that brother is an uncle for x. 

One bit of advice: make sure you run the reasoner after every rule and check each rule to make sure it's doing what you expect it to before writing more. You probably would do that anyway but I've seen at least one new user get into a situation that was very hard to debug because they wrote over 20 rules and then tried to debug them. 

Michael

On Fri, Apr 19, 2019 at 1:48 AM Bilel Abderrahman <[hidden email]> wrote:
hi; 
please i need to convert a text written in english to swrl rules. each line contain if..then. 
i need to convert each line to swrl automatically to enrich my ontology
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user

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

Re: text to swrl

Lorenz Buehmann

An algorithm for what?

And an SWRL API example code is linked in the SWRL API Wiki [1] which Michael already referred to.


[1] https://github.com/protegeproject/swrlapi/wiki

think you
you can give an example of algorithm or code java ?

Le ven. 19 avr. 2019 à 16:00, Michael DeBellis <[hidden email]> a écrit :
To my knowledge there is no tool that just converts text to SWRL rules. IMO you don't really need such a tool because once you understand the semantics of SWRL rules the mapping from axioms about your ontology to SWRL rules is so straight forward. I wrote a short SWRL tutorial that can be found here: https://symbolicshacker.blogspot.com/2017/06/swrl-process-modeling-tutorial.html  

Martin's presentation on SWRL is also excellent and something I think every new user should look through carefully. Especially for understanding things like the Open World Assumption and the lack of support for negation as failure which are different than most other rule systems: https://protege.stanford.edu/conference/2009/slides/SWRL2009ProtegeConference.pdf  

The documentation for the SWRLTab can be found here: https://github.com/protegeproject/swrlapi/wiki  

There are also other links in my tutorial. 

The basics of a SWRL rule are that the only connector is "^" (and). Also, every parameter must start with a question mark and all parameters on the left side are implicitly universally quantified and all on the right are implicitly existentially quantified. Also, class queries (left side) or assertions (right side) are treated as unary predicates and object properties as binary predicates. 

So if Human and Mortal are both classes the rule: 

Human(?x) -> Mortal(?x)    says that all Humans are Mortal. So if there was an individual named Socrates who was a Human but not a Mortal this rule would bind to Socrates on the left side and then assert that Socrates was also an instance of the Mortal class on the right side. 

Or if hasParent is an object property and hasBrother is an object property and hasUncle is an object property then the rule: 

hasParent(?x, ?y) ^ hasBrother(?y, ?z) -> hasUncle(?x, ?z)

Asserts that for all x if x has a parent and that parent has a brother then that brother is an uncle for x. 

One bit of advice: make sure you run the reasoner after every rule and check each rule to make sure it's doing what you expect it to before writing more. You probably would do that anyway but I've seen at least one new user get into a situation that was very hard to debug because they wrote over 20 rules and then tried to debug them. 

Michael

On Fri, Apr 19, 2019 at 1:48 AM Bilel Abderrahman <[hidden email]> wrote:
hi; 
please i need to convert a text written in english to swrl rules. each line contain if..then. 
i need to convert each line to swrl automatically to enrich my ontology
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user

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

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

Re: text to swrl

Kaarel Kaljurand
Hi,

you could look into Attempto Controlled English which comes with a
tool (https://github.com/Attempto/APE) that converts (restricted)
English texts into OWL or (if this fails) into SWRL. For example,

Every territory that is surrounded by a country X and that is a part
of a country Y that is not X is an enclave.

is mapped to:

Prefix(:=<http://attempto.ifi.uzh.ch/ontologies/owlswrl/test#>)
Prefix(ace:=<http://attempto.ifi.uzh.ch/ace#>)
Ontology(<http://attempto.ifi.uzh.ch/ontologies/owlswrl/test>
   DLSafeRule(
      Body(
         ObjectPropertyAtom(
            :part
            Variable(<urn:swrl#x2>)
            Variable(<urn:swrl#x3>)
         )
         ClassAtom(
            :territory
            Variable(<urn:swrl#x3>)
         )
         ClassAtom(
            :country
            Variable(<urn:swrl#x4>)
         )
         ObjectPropertyAtom(
            :surround
            Variable(<urn:swrl#x4>)
            Variable(<urn:swrl#x3>)
         )
         ClassAtom(
            :country
            Variable(<urn:swrl#x2>)
         )
         DifferentIndividualsAtom(
            Variable(<urn:swrl#x2>)
            Variable(<urn:swrl#x4>)
         )
      )
      Head(
         ClassAtom(
            :enclave
            Variable(<urn:swrl#x7>)
         )
         SameIndividualAtom(
            Variable(<urn:swrl#x3>)
            Variable(<urn:swrl#x7>)
         )
      )
   )
)



There is a demo webservice:

http://attempto.ifi.uzh.ch/ws/ape/apews.perl?text=Every%20territory%20that%20is%20surrounded%20by%20a%20country%20X%20and%20that%20is%20a%20part%20of%20a%20country%20Y%20that%20is%20not%20X%20is%20an%20enclave.&solo=owlxml

Best,
Kaarel

On Wed, Jul 3, 2019 at 9:11 AM Lorenz B.
<[hidden email]> wrote:

>
> An algorithm for what?
>
> And an SWRL API example code is linked in the SWRL API Wiki [1] which Michael already referred to.
>
>
> [1] https://github.com/protegeproject/swrlapi/wiki
>
> think you
> you can give an example of algorithm or code java ?
>
> Le ven. 19 avr. 2019 à 16:00, Michael DeBellis <[hidden email]> a écrit :
>>
>> To my knowledge there is no tool that just converts text to SWRL rules. IMO you don't really need such a tool because once you understand the semantics of SWRL rules the mapping from axioms about your ontology to SWRL rules is so straight forward. I wrote a short SWRL tutorial that can be found here: https://symbolicshacker.blogspot.com/2017/06/swrl-process-modeling-tutorial.html
>>
>> Martin's presentation on SWRL is also excellent and something I think every new user should look through carefully. Especially for understanding things like the Open World Assumption and the lack of support for negation as failure which are different than most other rule systems: https://protege.stanford.edu/conference/2009/slides/SWRL2009ProtegeConference.pdf
>>
>> The documentation for the SWRLTab can be found here: https://github.com/protegeproject/swrlapi/wiki
>>
>> There are also other links in my tutorial.
>>
>> The basics of a SWRL rule are that the only connector is "^" (and). Also, every parameter must start with a question mark and all parameters on the left side are implicitly universally quantified and all on the right are implicitly existentially quantified. Also, class queries (left side) or assertions (right side) are treated as unary predicates and object properties as binary predicates.
>>
>> So if Human and Mortal are both classes the rule:
>>
>> Human(?x) -> Mortal(?x)    says that all Humans are Mortal. So if there was an individual named Socrates who was a Human but not a Mortal this rule would bind to Socrates on the left side and then assert that Socrates was also an instance of the Mortal class on the right side.
>>
>> Or if hasParent is an object property and hasBrother is an object property and hasUncle is an object property then the rule:
>>
>> hasParent(?x, ?y) ^ hasBrother(?y, ?z) -> hasUncle(?x, ?z)
>>
>> Asserts that for all x if x has a parent and that parent has a brother then that brother is an uncle for x.
>>
>> One bit of advice: make sure you run the reasoner after every rule and check each rule to make sure it's doing what you expect it to before writing more. You probably would do that anyway but I've seen at least one new user get into a situation that was very hard to debug because they wrote over 20 rules and then tried to debug them.
>>
>> Michael
>>
>> On Fri, Apr 19, 2019 at 1:48 AM Bilel Abderrahman <[hidden email]> wrote:
>>>
>>> hi;
>>> please i need to convert a text written in english to swrl rules. each line contain if..then.
>>> i need to convert each line to swrl automatically to enrich my ontology
>>> _______________________________________________
>>> protege-user mailing list
>>> [hidden email]
>>> https://mailman.stanford.edu/mailman/listinfo/protege-user
>>
>> _______________________________________________
>> protege-user mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protege-user
>
>
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user
>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user