How to query for a mix of direct-type and :type relationships

Hi, is there a way in OpenLink Virtuoso to write a SPARQL query that specifies direct-type relationships, even when inferencing is enabled so that indirect-type relationships would be returned by rdf:type?

I’m looking for something like a :directType predicate.

I’m similarly interested in a :directSubClassOf predicate.

Thanks!

Not sure specifically what you mean by direct and indirect type relationships, but we have documentation on the Virtuoso builtin inferencing and reasoning support, with tutorial examples available. There is also documentation on Virtuoso custom inferencing and reasoning enabling pretty much any inference/reasoning rule to be created.

I hope this helps …

@jcl94110 - There is no “magic predicate” along these lines.

Perhaps this “retrieving most specific classes of instances” Q&A on StackOverflow will give you some idea of how what I think you’re looking for can be achieved?

Note that the queries there will only deliver the most specific type if a query using inferencing is run on an instance where inferencing is enabled, and where all ontological subtype relations are fully loaded.

A query run without inferencing active will return whatever type information is explicit in the loaded data, whether that is only the “most specific” or includes encompassing supertypes.

Thanks @TallTed. Yes, I should have been more specific - I was making the simplifying assumption of a graph in which explicit rdf:type relationships would only have been asserted for the most specific types (i.e., no explicit assertions of rdf:type relating individuals to encompassing supertypes).

Yes, I’m looking for a “magic predicate” that operates over a graph where inferencing is enabled but still only returns explicit rdf:type relations, excluding any inferred types. I hadn’t seen that StackOverflow question - thanks! - but I did find one about direct superclasses, which refers to a Jena-specific solution; I was wondering if an analogous solution was available in Virtuoso.

“Magic Predicates” are the product of Custom Inference Rules, i.e., you describe the subjects and objects of a custom predicate in your rule. Virtuoso lets you achieve this goal using SPARQL CONSTRUCT queries, building on terms from the SPIN Ontology.

Your first step would be to create a CONSTRUCT Query that matches your desired outcome. Once that’s in place, you simply use it as the Custom Inference Rule basis.

Related