On Sat, 2011-09-03 at 12:48 -0400, Phillip Rhodes wrote:
> On Sat, Sep 3, 2011 at 11:57 AM, Dave Reynolds
> <[email protected]> wrote:
> > A basic set up is very easy:
> >
> > [[[
> > Model data = FileManager.get().loadModel("data/test.rdf");
> > List<Rule> rules = Rule.rulesFromURL("file:data/test.rules");
> > GenericRuleReasoner reasoner = new GenericRuleReasoner(rules);
> > InfModel inf = ModelFactory.createInfModel(reasoner, data);
> > inf.setNsPrefixes( data );
> > inf.write(System.out, "Turtle");
> > ]]]
> >
> > where data/test.rdf is your file with entities defined and
> > data/test.rules is:
> >
> > [[[
> > @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> > @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
> > @prefix owl: <http://www.w3.org/2002/07/owl#> .
> > @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
> > @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
> >
> <snip>
> >
> > example:Milk
> > a skos:Concept ;
> > skos:narrower example:MilkBySourceAnimal , example:SheepMilk ,
> > example:BuffaloMilk , example:CowMilk , example:GoatMilk .
> > ...
>
> Cool, thanks! One question though... from what I read on the jena docs page
> on
> using the GenericRuleReasoner[1], I got the impression that if you
> wanted to combine
> custom rules with the "stock" rules, you had to do some sort of import in the
> rule file (eg, your "test.rules").
Yes, your example didn't actually need any OWL inference so I hadn't
included that. In your rule set put:
@include <OWLMicro> .
(there are predefined names for all the built in rule sets and they are
retrieved from the jar, so no need to locate them in the file system).
You also need to set two flags on the reasoner instance before you bind
it to an InfModel:
reasoner.setTransitiveClosureCaching(true);
reasoner.setOWLTranslation(true);
Dave