Johan Kumps
Johan Kumps

Reputation: 31

How to get a simple inferencing example to work

I might have understood something wrong, so bear with me.

prefix sys: <http://www.ontotext.com/owlim/system#>
INSERT DATA {
    <_:pets> sys:addRuleset
        '''Prefices { ex : <http://www.example.com#> }
           Axioms {}
           Rules
           {
           Id: custom                   
              a <ex:hasPet> b
              ------------------------------------
              b <ex:hasOwner> a
           }'''
}
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX ex: <http://www.example.com#>
    PREFIX owl: <http://www.w3.org/2002/07/owl#>
    INSERT DATA { 
        <ex:hasPet> a <owl:ObjectProperty>;
            <rdfs:domain> <ex:Human>;
            <rdfs:range> <ex:Pet>.
        <ex:someHuman> <ex:hasPet> <ex:somePet>. 
    }
PREFIX sys: <http://www.ontotext.com/owlim/system#>
INSERT DATA {
    _:b sys:defaultRuleset "pets"
}
PREFIX ex: <http://www.example.com#>
select * where { 
    <ex:somePet> ?p ?o .
} limit 100 

to return the following inferred triple <ex:somePet> <ex:hasOwner> <ex:someHuman>

but unfortunately no inferred triples are present in the repository.

Could you please help me? Having a working example with the different steps to take will help me get rules to work in my application.

Thanks in advance! Kind regards

Upvotes: 1

Views: 139

Answers (1)

Damyan Ognyanov
Damyan Ognyanov

Reputation: 786

There are multiple issues, first IRIs, within the Prefixes section of the ruleset must be written without angle brackets, e.g. use ex : http://www.example.com# instead ...

also your data and sample query do not make use of the prefix ex but are absolute IRIs, e.g. instead of

INSERT DATA { 
        <ex:hasPet> a <owl:ObjectProperty>;
            <rdfs:domain> <ex:Human>;
            <rdfs:range> <ex:Pet>.
        <ex:someHuman> <ex:hasPet> <ex:somePet>. 
    }

rewrite to

INSERT DATA { 
        ex:hasPet a owl:ObjectProperty;
            rdfs:domain ex:Human;
            rdfs:range ex:Pet.
        ex:someHuman ex:hasPet ex:somePet. 
    }

Upvotes: 1

Related Questions