Well, we don't have any code examples other than what is in Pellet.java
(the command-line version). Here is a general outline of how it works:
// ontology and rules files
String ontFile = "http://www.mindswap.org/~kolovski/rules.owl";
String rulesFile = ontFile;
// load the ontology
Reasoner reasoner = new Reasoner();
OWLOntology ont = OntologyHelper.getOntology(URI.create( ontFile
) );
reasoner.setOntology( ont );
// load the rules
Set rules = RuleUtils.parseRules( rulesFile );
reasoner.getKB().setRules(rules);
// query the reasoner as usual
String ns =
"http://www.mindswap.org/~edna/swoopRules/examples/lubm_owllog.owl#";
OWLClass specialCourse = ont.getClass( URI.create( ns +
"SpecialCourse" ) ) ;
Set specialCourses = reasoner.allInstancesOf( specialCourse );
System.out.println( specialCourses );
The only additional thing you do is the two lines under "load the rules"
comment. Rest is standard OWL-API code (you can use Jena for the rest
but the part about loading rules requires OWL-API).
Unlike the example I use above, it is preferable to separate the
ontology file and and the rules (as in [1] and [2]) so the terms used in
SWRL syntax will not be treated as regular terms. If you put rules in a
different file you need to put an owl:imports to point to the ontology
where the terms are defined.
Pellet does not help you in anyway to create or serialize your own SWRL
rules. The OWL-API extension we use (for parsing) should have support
for creation and serialization of rules. If you want a UI to do that,
you can use Swoop (see [3] for more information - remember to "Enable
rules" under "Advanced" menu) or Protege SWRL editor [4].
Cheers,
Evren
[1] http://www.mindswap.org/~edna/swoopRules/examples/allogExampleO.owl
[2] http://www.mindswap.org/~edna/swoopRules/examples/allogExampleR.owl
[3] http://www.mindswap.org/~edna/swoopRules
[4] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLTab
Post by Cristiane YaguinumaHello,
Since it's been a week and no one answered me, I am sending this
message again. I'd like to study some code examples that uses SWRL and
Pellet reasoner, since I could not find it in the documentation. It
can be an example showing how to load SWRL rules in
a Pellet reasoner, how to create rules, etc.
Thanks and best regards,
Cristiane Yaguinuma.
_______________________________________________
Pellet-users mailing list
http://lists.owldl.com/mailman/listinfo/pellet-users
_______________________________________________
Pellet-users mailing list
Pellet-***@lists.owldl.com
http://lists.owldl.com/mailman/listinfo/pellet-users
_______________________________________________
Sponsored by Clark & Parsia, LLC <http://clarkparsia.com/>