Search code examples
rdfsemantic-webjenaowl

Setting up OWL reasoner in Jena


I am trying to define (in turtle) a symmetric, transitive predicate in Turtle and get inferences from it.

Here is how I defined my predicate:

:similar a owl:SymmetricProperty; a owl:TransitiveProperty .

How I use it (same turtle file):

:a :similar :b .
:b :similar :c .

Then I issue a sparkl query "select ?x where ?x :similar :c" hoping to get a and b.

I have tried to set up the model like this:

OntModel ont = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );      
ont.read("file:./myontology.turtle",null,"TURTLE"); 
InfModel model = ModelFactory.createInfModel(ReasonerRegistry.getOWLReasoner(), ont);

and then using InfModel in my QueryExecutionFactory.create. Does not work.

I have also tried just that:

OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_DL_MEM_RULE_INF );
model.read("file:./myontology.turtle",null,"TURTLE");

No luck either. What the right way? What am I missing?

Thanks in advance.


Solution

  • Found the answer. The following works just fine:

    OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF);
    model.read("file:./myontology.turtle",null,"TURTLE");
    

    I had some issues with prefixes. Also, I was declaring :similar as a class and was assuming that subclasses would inherit owl:SymmetricProperty and owl:TransitiveProperty. Does not seem to work that way