Which ontology in scope for SPARQL query

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Which ontology in scope for SPARQL query

Wannaby
This post was updated on .
Hello,

I'm trying some basic SPARQL queries on Protege 5.2.0.
I downloaded the pizza ontology from:

http://www.co-ode.org/ontologies/pizza/pizza.owl#

- saved on my local disk
- open owl file into Protege
- I successfully performed the query:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX prefipizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT ?abracadabralist        
WHERE
{ ?abracadabralist       rdfs:subClassOf           prefipizza:PizzaTopping
}

Protege shows the list of existing toppings under "abracadabralist" column:

http://www.co-ode.org/ontologies/pizza/pizza.owl#FishTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#MeatTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#CheeseTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#NutTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#HerbSpiceTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#SauceTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#FruitTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#VegetableTopping

Then, I deleted 2 topping classes from the ontology: NutTopping and
FruitTopping.
I saved the new ontology on local disk as pizzamodif3.owl (owl xml type).
 
Close/open Protege, then open pizzamodif3.owl, and apply the query again.
This time the deleted classes are missing:

http://www.co-ode.org/ontologies/pizza/pizza.owl#FishTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#MeatTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#CheeseTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#HerbSpiceTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#SauceTopping       
http://www.co-ode.org/ontologies/pizza/pizza.owl#VegetableTopping

Looks like the query has been applied to the new ontology, but I still have
the same prefix in the query:
PREFIX prefipizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>

so I guess the prefix is not really pointed by query engine, and the query
is applied to the ontology file "pizzamodif3.owl" I uploaded into Protege.

But when I try to change the uri with another owl:
PREFIX prefipizza: <http://www.molprof.jp/ontologies/aistlsarc.owl#>
instead of:
PREFIX prefipizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>

the SPARQL query returns no entries, so this time looks like the query is
applied to new remote ontology in the url, which has no PizzaTopping
classes.

The behaviour is not clear:
1) when load original pizza owl + query prefix original pizza owl = query on
original pizza owl
2) when load pizzamodif3 owl + query prefix original pizza owl = query on
pizzamodif3 owl
3) when load pizzamodif3 owl + query prefix other owl = query on other owl
Furthermore, when replacing the uri prefix with "abcdefgfgfgfgf.com",
Protege returns an error when executing the query, so I guess the http
connection is executed.

Can anybody explain which logic is followed to point the ontology when
executing a SPARQL query?

Thank you  




--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
protege-user@lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Which ontology in scope for SPARQL query

samsontu
Hi,

I don’t understand your comment about “query applied to new remote ontology.” So let me know if my comments are off-mark.

Entities in an OWL ontologies have IRIs like 



This is true regardless of what prefix you use in your SPARQL query. A prefix like prefipizza is just a shorthand so that you don’t have to write the entire IRI each time. When you query with PREFIX prefipizza: <http://www.molprof.jp/ontologies/aistlsarc.owl#>, you are making the query:

SELECT ?abracadabralist         
WHERE 
{ ?abracadabralist       rdfs:subClassOf           http://www.molprof.jp/ontologies/aistlsarc.owl#PizzaTopping 
}

Now, there is no entity in the loaded pizza ontology with such IRI. Therefore nothing is returned.

With best regards,
Samson



On Feb 14, 2019, at 2:56 PM, Wannaby <[hidden email]> wrote:

Hello,

I'm trying some basic SPARQL queries on Protege 5.2.0.
I downloaded the pizza ontology from:

http://www.co-ode.org/ontologies/pizza/pizza.owl#

- saved on my local disk
- open owl file into Protege
- I successfully performed the query:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX prefipizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT ?abracadabralist         
WHERE
{ ?abracadabralist       rdfs:subClassOf           prefipizza:PizzaTopping
}

Protege shows the list of existing toppings under "abracadabralist" column:

http://www.co-ode.org/ontologies/pizza/pizza.owl#FishTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#MeatTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#CheeseTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#NutTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#HerbSpiceTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#SauceTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#FruitTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#VegetableTopping

Then, I deleted 2 topping classes from the ontology: NutTopping and
FruitTopping.
I saved the new ontology on local disk as pizzamodif3.owl (owl xml type).

Close/open Protege, the open pizzamodif3.owl, and apply the query again.
This time the deleted classes are missing:

http://www.co-ode.org/ontologies/pizza/pizza.owl#FishTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#MeatTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#CheeseTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#HerbSpiceTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#SauceTopping
http://www.co-ode.org/ontologies/pizza/pizza.owl#VegetableTopping

Looks like the query has been applied to the new ontology, but I still have
the same prefix in the query:
PREFIX prefipizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>

so I guess the prefix is not really pointed by query engine, and the query
is applied to the ontology file "pizzamodif3.owl" I uploaded into Protege.

But when I try to change the uri with another owl:
PREFIX prefipizza: <http://www.molprof.jp/ontologies/aistlsarc.owl#>
instead of:
PREFIX prefipizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>

the SPARQL query returns no entries, so this time looks like the query is
applied to new remote ontology in the url, which has no PizzaTopping
classes.

The behaviour is not clear:
1) when load original pizza owl + query prefix original pizza owl = query on
original pizza owl
2) when load pizzamodif3 owl + query prefix original pizza owl = query on
pizzamodif3 owl
3) when load pizzamodif3 owl + query prefix other owl = query on other owl
Furthermore, when replacing the uri prefix with "abcdefgfgfgfgf.com",
Protege returns an error when executing the query, so I guess the http
connection is executed.

Can anybody explain which logic is followed to point the ontology when
executing a SPARQL query?

Thank you   




--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user

smime.p7s (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Which ontology in scope for SPARQL query

Wannaby
Thanks for reply.

You answered to one of my basic question: "on which ontology the query is
performed"?
Looking at your reply, I understand the answer is "the query is performed on
the ontology file you open in Protege, not on the ontology file placed in
the web"

But it is still not clear to me how the prefix works.
When you say: "there is no entity in the loaded pizza ontology with such
IRI", you mean the prefix written at the beginning of the query?
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>   <- - -
this one

Does the query need to point the pizza ontology on the web via http at
address "www.co-ode.org/..." and collect some data from the web?
I guess the answer is no, because we said the query points to the local
ontology (where I deleted 2 classes) loaded into Protege.
So, if I want to change this prefix in the query, why I can't? It is only a
prefix defined in the query.

My understanding was that changing this query prefix:
PREFIX prefipizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
into:
PREFIX prefipizza: <http://www.molprof.jp/ontologies/aistlsarc.owl#>
the PizzaTopping entity will be automatically renamed into:
http://www.molprof.jp/ontologies/aistlsarc.owl#PizzaTopping

But it does not work...
I don't understand where the system takes the decision that prefix must be
exactly:
http://www.co-ode.org/ontologies/pizza/pizza.owl#
 




--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Which ontology in scope for SPARQL query

Wannaby
finally I got it!

The problem was the content of my local owl file.
I took the owl file were I deleted 2 classes using protege, and open the
file with a text editor to see the definitions inside.
The file begins with the following prefix definitions:
<?xml version="1.0"?>
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
     xml:base="http://www.co-ode.org/ontologies/pizza"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     ontologyIRI="http://www.co-ode.org/ontologies/pizza"
     versionIRI="http://www.co-ode.org/ontologies/pizza/2.0.0">
    <Prefix name="" IRI="http://www.co-ode.org/ontologies/pizza"/>
    <Prefix name="dc" IRI="http://purl.org/dc/elements/1.1/"/>
    <Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
    <Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
    <Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
    <Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
    <Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
    <Prefix name="skos" IRI="http://www.w3.org/2004/02/skos/core#"/>
    <Prefix name="pizza"
IRI="http://www.co-ode.org/ontologies/pizza/pizza.owl#"/>
    <Prefix name="terms" IRI="http://purl.org/dc/terms/"/>

the http address www.co-ode.org is reported 5 times.
So I did this change: I saved a new version of the ontology where I replaced
all 'www.co-ode-org' with 'www.abracadabra1234.org'.

Then I disconnected my pc from internet (so I'm sure that protege cannot
collect data somewhere from the web)
I restarted protege and open the new ontology with the replaced
www.abracadabra1234.org prefix.
I executed the following query:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX lamiapizza:
<http://www.abracadabra1234.org/ontologies/pizza/pizza.owl#>
SELECT ?subject        
WHERE
{ ?subject       rdfs:subClassOf           lamiapizza:PizzaTopping
}

and it works!
Protege returned me the list of subclasses from my local ontology.
So the explanation of the behaviour is: the query http prefix of ontology
classes have to match the http prefix written inside the owl file of
ontology.
And you can use any kind of string as a prefix, protege will not match it
with other resources outside your pc. It is enough you set the same http
name for query prefix and owl details prefix.

Thanks and bye  




--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user