I have a question about SPARQL Query in Protege
I have a built ontology. This ontology includes a subclass called HVAC_CL. HVAC_CL subclass contains an individual called AirCondition_CL. AirCondition_CL as an individual is assigned to a Data property called InstallationPrice. The data property assertion for InstallationPrice is 4000 (as an integer value).
I need a SPARQL Query in Protege to identify the InstallationPrice of the AirCondition_CL individual.
Related
I have 2 questions regarding Sparql:
I have a class and I'm trying to get all instances of a certain class. I'm using Protege. There are 2 instances for the 'Actor' class. How can I write a sparql query to extract only these two values?
Additional to question 1, how can I match only one value. For example how do I modify Question 1's query to match == "Third Party API"?
I am using an IBM wrapper solution around SPARQL to get information from our database. I set a triple variable to act as a filter but it doesnt return an exact match, only a 'contains' match.
More specifically, we are looking at requirements that live in a collection. The SPARQL query returns all requirement objects and the collection that they live in. Each collection has a unique identifier associated with it which is accessed via the predicate 'dcterms:identifier'. The exact line in the SPARQL code which does this is:
?oslc_rm_RequirementCollection1_uri dcterms:identifier ?oslc_rm_RequirementCollection1_identifier
This works as expected. In the output I get a table containing each collection with the list of requirements associated with each one.
The problem arises when I want to look at requirements in only a specific collection. To do this I set the variable oslc_rm_RequirementCollection1_identifier in IBM's wrapper, and it generally works. If I enter '18732' it only shows me requirements from the collection with id 18732. However, this is not an exact match only a contains. For example if I enter '867', I am shown two collections: 867 and 38674.
How can I modify this to exclude 38674 and only show the exact match? I cannot use a string literal because the wrapper does not allow this.
Can SPARQL be used to query an empty ontology (with no individuals), to retrieve information about the restrictions (axioms or object properties) put on a class?
Here's a snippet of my ontology in turtle syntax:
How can a SPAQRL query, if possible, be formulated to retrieve the following triples from the ontology:
And if not possible to do this directly with SPARQL, is there a workaround for it using dotNetRDF OntologyAPI?
Thanks in advance!
I tried one SPARQL query in two different engines:
Protege 4.3 - SPARQL query tab
Jena 2.11.0
While the query is the same the results returned by these two tools are different.
I tried a DESCRIBE query like the following:
DESCRIBE ?x
WHERE { ?x :someproperty "somevalue"}
Results from protege give me tuples that take ?x as subject/object; while the ones from jena are that take ?x as subject only.
My questions are:
Is the syntax of SPARQL uniform?
If I want DESCRIBE to work as in protege, what should I do in Jena?
To answer your first question yes the SPARQL syntax is uniform since you've used the same query in both tools. However what I think you are actually asking is should the results for the two tools be different or not? i.e. are the semantics of SPARQL uniform
In the case of DESCRIBE then yes the results are explicitly allowed to be different by the SPARQL specification i.e. no the semantics of SPARQL are not uniform but this is only in the case of DESCRIBE.
See Section 16.4 DESCRIBE (Informative) of the SPARQL Specification which states the following:
The query pattern is used to create a result set. The DESCRIBE form
takes each of the resources identified in a solution, together with
any resources directly named by IRI, and assembles a single RDF graph
by taking a "description" which can come from any information
available including the target RDF Dataset. The description is
determined by the query service
The important part of this is the last couple of sentences that say the description is determined by the query service. This means that both Protege's and Jena's answers are correct since they are allowed to choose how they form the description.
Changing Jena DESCRIBE handling
To answer the second part of your question you can change how Jena processes DESCRIBE queries by implementing a custom DescribeHandler and an associated DescribeHandlerFactory. You then need to register your factory like so:
DescribeHandlerRegistry.get().set(new YourDescribeHandlerFactory());
I knew this might be a stupid question but I don't know the answer :)
I am using protege4 I built my ontology and when I tried to use DL Query from the DL query tap in protege4 it executes fine and I get results.
However, when I click "Add to ontology" to add my query to the ontology it adds it but without any query results!!! Why are there no query results? and how to see it?
Thanks
First some terminology:
Every OWL ontology is a set of OWL axioms.
Every DL-Query is an OWL class expression.
Every DL-Query result is a set of OWL entities.
You can only add axioms to an ontology. You cannot add class expressions nor sets of entities to an OWL ontology.
The "Add to ontology" button seems to create a new EquivalentClasses-axiom on the basis of the query (i.e. class expression), and a named class (given by the user), and then asserts this axiom into the active ontology, i.e.
EquivalentClasses(new_name query)
(I didn't quite get it working like this in my version of Protege 4, but such a functionality would make sense.)
The current OWL2 specification does not say anything about how to store class expressions and query results in the ontology. These have to be specified and calculated every time from scratch after you load the ontology from the file.