There is a W3C standard on entailment regimes in SPARQL. However, it does not mention how an entailment regime should be specified in a SPARQL query. Nor does it give any examples. I haven't found a single example of the Web either... So how does one specify entailment regimes in a SPARQL query? Can it be done at all?
PREFIX ex: <http://www.example.com/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?property
WHERE {
?property rdfs:subPropertyOf ex:someTopProperty .
}
I would like bindings for ?property to be closed under transitivity (part of RDFS entailment).
Entailment regimes are an optional extension point of SPARQL so there is no requirement for a SPARQL engine to support entailment regimes.
Where entailment regimes are supported how these are enabled is an implementation specific detail and not specified/standardised anywhere. Some engines may allow you to only specify a single entailment regime which is always on while others may allow you to change entailment regimes on a per-query basis.
Generally you should contact the vendor(s) of the SPARQL engines you are wanting to use to see what entailment regimes they support and how that support is configured and enabled.
Edit
As for how you determine what entailment regime is used you can try and get the SPARQL 1.1 service description of an endpoint which may include properties such as sd:defaultEntailmentRegime
However that information (if an endpoint provides it) would typically only tell you about the configuration of the endpoint and not necessarily about possible configurations
Related
Is it possible to infer new knowledge about an ontology only from a query in SPARQL?
I have a question about the use of the SPARQL language about ontologies. So far I have thought that SPARQL is the equivalent to the SQL language in the relational databases, that is to say, that with SPARQL it is only possible to consult the data that are explicitly in the ontology, without having access to the data that can be inferred , leaving the responsibility of the inference to the reasoners.
However, I have read documents from which I infer that SPARQL does have the capacity to infer implicit and non-explicit knowledge in the ontology. Is my inference true? That is, is it possible to infer knowledge through a SPARQL query without the need for a reasoner? If the answer is true, then what advantages does the use of a reasoner have over the use of SPARQL?
Greetings, Manuel Puebla.
Yes, on-the-fly inference may be a feature of the SPARQL processor, so you can get the benefits of inference/reasoning directly from a SPARQL query. (See Virtuoso SPARQL endpoints inference rules for some discussion of how this is done in Virtuoso, for example.)
Is there a plug-in or other means to create and edit SPARQL/SPIN constraints and constructors in Protege?
As I understand it, to capture SPIN constraints in RDF, the SPARQL code for the ASK or CONSTRUCT queries needs to be parsed and encoded. It's not stored as an opaque string. Therefore, it would seem that some plugin with knowledge of SPARQL and SPIN would be required.
I've loaded RDF from Topbraid Composer including SPIN constraints into Protege 4.3.0, and it seems to see the constraints as annotations, but I cannot seem to find all of the details, critically including all of the underlying SPARQL code. I do see it when text editing the RDF file.
In the broad sense, I'm trying to find a way to create/edit SPIN constraints and constructors and load them into Sesame to have them operate on individuals instantiated from my classes. I posted another question about the path from TopBraid Composer into Sesame. I'm trying to keep my questions more specific since I'm a newbie on Stack Overflow.
BTW, no I don't want to use SWRL instead. I've had trouble expressing the constraints I need using SWRL. I've had success using SPARQL.
Thanks.
In some versions TopBraid Composer will store SPIN constraints in RDF by default. Given that the query is stored as RDF triples, there should be no problem storing them in any RDF data store. Applying the SPIN constraints is a different issue, as the system will need to know how to interpret the queries for different SPIN properties.
Are you certain you cannot "see" them in Protégé or Sesame? The constraints are defined on the class using the property spin:constraint and should appear as a bnode. Make sure you also import http://spinrdf.org/spin, or at least define a property named spin:constraint. In the very least, the following should always work to find your constraints:
SELECT ?constraint ?class
WHERE {
?class <http://spinrdf.org/spin#constraint> ?constraint
}
...where ?constraint is bound to a bnode representing the constraint in RDF and ?class is the class the constraint is defined for.
Also, if you would rather store the constraints as SPARQL strings, see Preferences > TopBraid Composer > SPIN and check one of the boxes in "Generate sp:text...". Then you can get the query text via the following query:
SELECT ?query ?class
WHERE {
?class <http://spinrdf.org/spin#constraint> ?constraint .
?constraint <http://spinrdf.org/sp#text> ?query
}
I am using SPARQL plugin in protege to query my ontology, and I found out that it only works for asserted statements and not inferred ones. How can I change this?
SPARQL is defined by several standards. SPARQL 1.1 Query, the main standard, only shallowly relies on RDF semantics. A typical SPARQL query engine is not inferring anything from the RDF/RDFS terms like rdfs:subClassOf, rdfs:range, etc. However, the SPARQL standards also define SPARQL 1.1 Entailment Regimes, which defines how SPARQL engines should answer queries when they do implement inference, which is optional. In order to know whether a SPARQL query engine implements an entailment regime (such as RDFS or OWL DL), you may have to look at the documentation of the engine, or there may be a SPARQL service description available in RDF. SPARQL 1.1 Service Description is yet another SPARQL standard that provides an RDF vocabulary, and a standard way to interpret it, for knowing what features a SPARQL engine is implementing.
When querying some linked data SPARQL endpoints via SPARQL queries, what is the type of reasoning provided (if any)?
For example, DBpedia SNORQL endpoint doesn't even provide the basic subclass inference (if A subClassOf B and B subClassOf C, then A subClassOf C). While FactForge SPARQL endpoint provides some inference (though it is not clear what kind of inference it is), and provides the possibility to switch that inference on and off.
My question:
How is it possible to identify the kind of inference applied? and if the inference support is limited, could it be extended using the endpoint only?
Inference controls will vary with the engine as well as the endpoint.
The public DBpedia SPARQL endpoint (powered by Virtuoso, from my employer, OpenLink Software) does provide various inference rules (accessible through the "Inference rules" link at the top right corner of the SPARQL endpoint query form page) which are controlled by pragmas in your SPARQL (not SNORQL, to which form you linked), such as --
DEFINE input:inference 'urn:rules.skos'
You can see the content of any predefined ruleset via SPARQL -- for the above
SELECT *
FROM <urn:rules.skos>
WHERE { ?s ?p ?o }
You can see the live query and results.
See this tutorial containing many examples.
While inference is not universally supported across SPARQL endpoints, most of the inferences supported by RDFS, RSFS+ and OWL 2 RL profiles are supported by SPARQL itself. For example, querying for instances of :A using your subClassOf entailment can be supported with SPARQL property paths:
SELECT ?inst
WHERE {
?cls rdfs:subClassOf* :A .
?inst a ?cls .
}
The first triple pattern gets all subclasses of :A, including :A (use + instead of * if you just want subclasses of :A), and the second triple finds all instances of all those classes.
To see how most of OWL 2 can be implemented with SPARQL, see Reasoning in OWL 2 RL and RDF Graphs using Rules. With a couple of exceptions, all of these can be implemented in SPARQL (and in fact you probably won't need some of them, such as eq-ref, (which is good for a computational lol that logicians may scoff at)).
There are few uses cases, beyond heavy-lifting classification problems, that can't be solved with a subset of the OWL 2 RL rules.
So, in the end, a recommendation is to understand what entailments you need. Chances are that OWL has totally overthought the issue and you can live with a few SPARQL patterns. And then you can hit the SPARQL endpoints without having to worry about whether specific inference profiles are supported.
I'm trying several queries on the site : http://geosparql.org/
I'm very interested in trying the clause : NEARBY, for example this query using NEARBY in this way:
PREFIX spatial:<http://jena.apache.org/spatial#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX geo:<http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX gn:<http://www.geonames.org/ontology#>
Select *
WHERE{
?object spatial:nearby(40.74 -73.989 1 'mi').
?object rdfs:label ?label
}LIMIT 10
When i execute the query on site http://geosparql.org/ all is ok but now i desire download the GeoNames Ontology and execute it on my PC.
here i have found the ontology for download: http://www.geonames.org/ontology/documentation.html
He tells me that The Ontology for GeoNames is available in OWL :
http://www.geonames.org/ontology/ontology_v3.1.rd
I download it but when i open ontology with software Protegè or with Sparql Droid on my smarphone Android and execute same query I get no data maybe the ontology is empty?
How do I fill the ontology, in order to run this query?
Thank you very much to those who will help me.
The ontology is the vocabulary (i.e., definition of classes, properties, etc.) An ontology doesn't necessarily include the individuals (e.g., the places, locations, etc.) that you might be interested in. In this case, I think you've downloaded the ontology, which is relatively small, but you're probably interested in the data dumps that that page describes later. I think the fourth option is the one that you want:
Entry Points into the GeoNames Semantic Web
There are several ways how you can enter the GeoNames Semantic Web :
…
RDF dump with 10113356 features and about 150 mio rdf triples (2015 04 21). The dump has one rdf document per toponym on every line of the
file. Note: The file is pretty large. Make sure the tool you use to
uncompress is able to deal with the size and does not stop after 2GB,
an issue that happens with some old (windows) tool versions.
Open the web page geonames then Clic on the given OWl URI Geonames Ontology the geonames onto is then downloaded. open protégé then menu File> Open and import the owl document the ontology concepts is then added to protégé; use it to add your own instanc