|
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. Thank you for your answear. Symetricity is desirable because the my:newtriple is my own version of sameAs (sameAsCandidate) so it has to be symetrical. After all I had to change my reasoning strategy because the real ontology consists of more subclasses (SubClassOne rdfs:subClassOf MainClass1 rdfs:subClassOf MainClass2 rdfs:subClassOf MainClass3) and it is not possible to FILTER results because FILTER is performed after WHERE clause is done. And it would be total performance killer. @Andy, Speaking of symmetry, I edited some out of your answer. :) |

