Getting all SWRL rules of an ontology

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

Getting all SWRL rules of an ontology

Stefan
Hi,

is there a simple way of retrieving all SWRL rules of an ontology?
Reply | Threaded
Open this post in threaded view
|

Re: Getting all SWRL rules of an ontology

Jiba
Administrator
Hi,

You can use ontology.rules(), which returns a generator.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Getting all SWRL rules of an ontology

Stefan
Thanks. Is there also a way to get label/name/iri of a rule? The usual attributes all seem to hold empty strings, but I can find the rules using these when I use ontology.search().
Reply | Threaded
Open this post in threaded view
|

Re: Getting all SWRL rules of an ontology

Jiba
Administrator
Hi,

By default, rules are created as blank nodes, so they have no IRI or name.

If you want to create a named rule, pass its name to the constructor : Imp("rule_name").

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Getting all SWRL rules of an ontology

Stefan
Hi,

turns out the attribute I was looking for was "label", not "name". It works now, but maybe this should be documented somewhere.