The default behavior of the SPARQL DESCRIBE command is to return all statements where the specified URI is the subject value (ex: describe <some uri>). Many applications require a much richer description of a resource that may include information about referenced URIs also. When using Intellidimension Semantics the behavior of the DESCRIBE command can be modified by providing some special inference rules. The DESCRIBE command gets its behavior from a special inference rules call <description>. This rule (“relation”) takes four arguments as shown below.
The first three arguments are the statements describing the URI in the fourth argument.
select ?s ?p ?o ?r where {?s ?p ?o. filter(?s=?r)} as <description>
So consider the first three arguments outputs and the fourth as an input. This relation provides the default implementation of the DESCRIBE command by returning all statements about a specified URI.
To customize the DESCRIBE command, you must provide one or more rules that implement the <description> relation. For example, if you wanted to create a custom description for a factory entity that included information about chemicals it uses you could implement the following rules and include them in your DESCRIBE query.
rulebase (
select ?s ?p ?o ?r where {
?r x:usesChemical ?s.
?s ?p ?o.} as <description>
)
describe <somefactoryuri> from <data>
By adding this rule you will now get all statements about the factory plus all statements about any chemicals it uses. So you can now create different sets of rules for different entity types each with its own custom description.
Another way to accomplish this goal is to add some additional information to your ontology so that a single set of rules can be used for all entity types. For example if we added the statement {x:FactoryClass x:includedReference x:usesChemical} to the ontology a generic set of description rules could be written as follows.
rulebase (
select ?s ?p ?o ?r where
{?s ?p ?o. filter(?s=?r)} as <description>
# special rule to look for all marked predicates for the
# class of the entity (?r) and recursively describe all
# included references.
select ?s ?p ?o ?r where {
?r rdf:type ?class.
?class x:includedReference ?ref.
?r ?ref ?included.
<description>(?s, ?p, ?o, ?included).
}as <description>
)
describe <somefactoryuri>