Hi Andy,


I have something more like a structure of classes (iii) in the base model with 
a named instance, let’s call it i1 that implements A.  I want to get back [i1, 
A] from a SPARQL query that looks for a instance inherited from C. I can get 
the result I want with no reasoner enabled.  When I turn on the OWL reasoner 
the inferred relations that are created as in (ii) are giving me back [i1, A],  
[i1, B], and [i1, C] from my query.  

I’m trying to force the use of a reasoner into some aspect of my sample 
application and I believe what this is uncovering is that my OO modeling of the 
ontology does not require the OWL reasoning in this case. I might be better off 
not worrying about inferring relationships within the ontology. Instead I might 
need to use a generic reasoner and look for rules that can be applied to infer 
some knowledge that what normally need to be generated from the SPARQL results 
in code. 

Thanks,
Chris



> On Dec 22, 2015, at 3:29 PM, Andy Seaborne <[email protected]> wrote:
> 
> On 22/12/15 19:09, A. Soroka wrote:
>> Were you using that with an inferring model? Because then you are going to 
>> materialize a bunch of fresh rdf:type triples, which are going to turn up as 
>> the other (super) classes.
> 
> 
> Chris : "directly implemented" -- do you mean direct subclasses?
> 
> http://jena.apache.org/documentation/inference/index.html#directRelations
> 
> C is not a direct subclass of A.
> 
> There is some secret predicate when querying an inference model (not sure 
> what it is. Dave?) that will trigger direct subclass calculation. If you want 
> SPARQL and use the right predicate it should work.
> 
> Otherwise on the base data, not the inference model:
> 
> A quick hack in SPARQL for a non-inference model for direct subClassOf:
> 
> # ?x is a direct subclass of ?C if
> # there is not a another, longer route to it.
> PREFIX :        <http://example/>
> PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
> 
> SELECT * {
>  ?x rdfs:subClassOf ?C .
>  FILTER NOT EXISTS { ?x rdfs:subClassOf/rdfs:subClassOf+ ?C }
>  }
> 
> --------------------------------------
> 
> @prefix :        <http://example/> .
> @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
> 
> :B rdfs:subClassOf :A .
> :C rdfs:subClassOf :A .
> :C rdfs:subClassOf :B .
> :D rdfs:subClassOf :B .
> 
> -----------
> | x  | C  |
> ===========
> | :C | :B |
> | :D | :B |
> | :B | :A |
> -----------
> 
>> 
>> ---
>> A. Soroka
>> The University of Virginia Library
>> 
>>> On Dec 22, 2015, at 1:58 PM, Chris Snyder <[email protected]> wrote:
>>> 
>>> Yeah, I tried that route but it still returns all the class in the 
>>> inheritance structure.
>>> 
>>> Thanks,
>>> Chris
>>> 
>>> 
>>>> On Dec 22, 2015, at 11:52 AM, A. Soroka <[email protected]> wrote:
>>>> 
>>>> I am _no_ SPARQL guru, but I think you might be able to do this without 
>>>> inference, with property paths:
>>>> 
>>>> 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 modelica: <http://mind-tap.net/kbswt/modelica#>
>>>> 
>>>> SELECT ?instance ?label
>>>> WHERE {
>>>> ?instance rdf:type ?type.
>>>> ?type rdfs:subClassOf+ modelica:BinaryExpression .
>>>> ?type rdfs:label ?label.
>>>> }
>>>> 
>>>> ---
>>>> A. Soroka
>>>> The University of Virginia Library
>>>> 
>>>>> On Dec 22, 2015, at 11:41 AM, Chris Snyder <[email protected]> wrote:
>>>>> 
>>>>> I’m using the Jena OWL reasoner with this ontology:
>>>>> http://www.mind-tap.net/kbswt/simple_no_inheritance.ttl
>>>>> 
>>>>> I want to get the named individuals that are instances of a 
>>>>> modelica:BinaryExpression along with the rdfs:label of the class directly 
>>>>> implemented by the named individual.
>>>>> 
>>>>> I hope there is a SPARQL guru who can help identify what I need to do. If 
>>>>> adding a Jena rule to the reasoner would help I have no problem going 
>>>>> that route either.
>>>>> 
>>>>> In essence:
>>>>> c subClassOf b
>>>>> b subClassOf a
>>>>> 
>>>>> c rdfs:label “class c”
>>>>> b rdfs:label “class b”
>>>>> a rdfs:label “class a”
>>>>> 
>>>>> x typeOf c
>>>>> x rdfs:label “instance x”
>>>>> 
>>>>> I need to run a query to get:
>>>>> “instance x”, “class c”
>>>>> 
>>>>> but my SPARQL gives me:
>>>>> “instance x”, “class c”
>>>>> “instance x”, “class b”
>>>>> “instance x”, “class a”
>>>>> 
>>>>> I’ve tried some filter expressions but they wind up filtering out all the 
>>>>> results. I was thinking there is some path modifier that might work but 
>>>>> haven’t been successful going down that route either.
>>>>> 
>>>>> My starter SPARQL:
>>>>> 
>>>>> PREFIX modelica: <http://mind-tap.net/kbswt/modelica#>
>>>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>>> PREFIX : <http://mind-tap.net/kbswt/simple_no_inheritance#>
>>>>> 
>>>>> select distinct * { ?s rdfs:subClassOf modelica:BinaryExpression ;
>>>>> rdfs:label ?equationName .
>>>>> ?i a ?s.
>>>>> }
>>>>> ORDER BY ?i
>>>>> 
>>>>> Thanks in advance,
>>>>> Chris
>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 

Reply via email to