|
[Moved from answer here on "query using SPARQL with RDF inference model (reasoner)". /Signified] To get SPARQL query results based on inferences, for example, the RDFS sub-class rule needs to be applied on the dataset (i.e. using a reasoner). After that I can use the original SELECT-query. But what if I don't have the possibility to run a reasoner on my dataset (for example if I have a remote dataset which I can't write on or if the dataset is just too large and running a reasoner would be too time consuming). Is there a way to use the rule with the SPARQL-query. |
|
Writing a generic reasoner on top of an external plain-ol' SPARQL engine is possible for something like RDFS using multiple queries, but won't be very efficient in many cases. You could query for all of the RDFS schema information and then cache that, using it on the client side for a technique called "query-rewriting". (This might be an interesting research problem.) However, the more practical option in many scenarios is to try capture the inference directly in the query. For example, to find all instances of
(Edited to use zero-to-many match instead of union based on Andy's comment. Thanks!) Of course, with this approach, you would not find instances inferred to be |
|
Building on @Signified's answer: you can cache locally for any given query (with any set of rules). Take each of the triple, or quad patterns in the query, break them out of the query and run them separately, then cache them in your triple store. Then run your inferences and add them to the cache. Then run your original query on your cache. This doesn't always work if any of the individual triple/quad patterns return results that are too large to transmit or store. |
|
Building on @harschware's answer, you don't have to limit yourself to your remote store's intended semantics. If you use a CONSTRUCT query to extract out your triples, you can merge that with any old ontology you come up with, using a reasoner on the whole. |


I'm converting this to a separate question. ;)