Hello, I need help of semantic guru's :). I want to create query which I plan to use as some kind of inferencing. The situation is following. We have class MainClass which has x subClasses: SubClassOne, SubClassTwo, SubClassThree... The subclasses consist of individuals. I need to match( insert new triple ) the individuals inside each subclasses if some triples fulfil my conditions. I will try to explain it in some pseudo code.
The first problem with the query is condition: ?aClass hasTheSameClassAs ?bClass . The problem is that ?a is rdf:type MainClass and at the same time it is for example rdf:type SubClassOne. It means for every individual there will be at least one match which is not desirable. I want to match only individuals within subClasses.
The second problem is performance. I'm aware of high complexity of the query, but I hope there is better way of matching individuals using SPARQL syntax. Thank you for any answer. Marek
Details matter but fro what I read into the question ...
The whole thing is symmetric in ?a and ?b so for every:
there will be
Do you want that?
To match only on subclasses:
A simple approach is to eliminate the match of ?aClass with the top of the hierarchy with
Then you can find the cases where there is a class in common with
But this is the same in effect as:
Putting it together:
Efficiency: using ?class and not ?aClass and ?bClass should help. One less cross-product.