You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Andrés Zules <fa...@gmail.com> on 2012/04/10 02:58:42 UTC

Simple Pizza Query

Hi everyone

I use Protege Version 3.4.7 (Build 620) and execute a simple query in the
SPARQL Query Panel on http://www.co-ode.org/ontologies/pizza/pizza.owl:

SELECT ?NombrePizza
> WHERE {
>  ?NombrePizza ?Relacion pizza:MushroomTopping .
>  ?Relacion owl:inverseOf pizza:isToppingOf .
> }


The result is 4 pizzas:

 DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons)

  DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#Mushroom)

  DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#Giardiniera)

  DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#LaReine)


Then I execute the same query with jena

package Jena;
> import com.hp.hpl.jena.graph.query.Query;
> import com.hp.hpl.jena.query.*;
> import com.hp.hpl.jena.rdf.model.*;
> import com.hp.hpl.jena.reasoner.Reasoner;
> import com.hp.hpl.jena.reasoner.ReasonerRegistry;
> import com.hp.hpl.jena.reasoner.ValidityReport;
> import java.util.Iterator;
> public class Test {
>
>     public static void main(String args[]) {
>         Model model = ModelFactory.createDefaultModel();
>         model.read("http://localhost:8080/volcano/w3/pizza-latest.owl",
> "RDF/XML");
>
>         model.write(System.out);
>
>         Reasoner reasoner = ReasonerRegistry.getOWLMicroReasoner();
>         InfModel inf = ModelFactory.createInfModel(reasoner, model);
>
>         ValidityReport validity = inf.validate();
>         if (validity.isValid()) {
>             System.out.println("OK: El Modelo Inferido es correcto.");
>         } else {
>             System.out.println("Conflictos");
>             for (Iterator i = validity.getReports(); i.hasNext();) {
>                 System.out.println(" - " + i.next());
>             }
>         }
>
>         inf.write(System.out);
>
>         String prefix = "PREFIX pizza:<
> http://www.co-ode.org/ontologies/pizza/pizza.owl#>"
>                 + " PREFIX owl:<http://www.w3.org/2002/07/owl#>"
>                 + " PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>";
>
>         String queryString1 = prefix + " SELECT ?NombrePizza WHERE {"
>                 + " ?NombrePizza ?Relacion pizza:MushroomTopping ."
>                 + " ?Relacion owl:inverseOf pizza:isToppingOf }";
>
>         com.hp.hpl.jena.query.Query query =
> QueryFactory.create(queryString1) ;
>         QueryExecution qexec = QueryExecutionFactory.create(query, inf);
>
>         try {
>             ResultSet results = qexec.execSelect() ;
>             ResultSetFormatter.out(results, query);
>         } finally {
>             qexec.close();
>         }
>     }
> }


And the result is empty:

-----------------------
> | NombrePizza |
> ============
> -----------------------


I don't know what is my mistake. Do you have any idea?. Thank you very much.

- - -
FAZA

Re: Simple Pizza Query

Posted by Andrés Zules <fa...@gmail.com>.
WOW ... I used  http://sparql.org/sparql.html and the results are the same
that Jena ... The problem is with protegé, i think ... excuseme everyone
... :D

2012/4/13 Andrés Zules <fa...@gmail.com>

> 2012/4/10 Dave Reynolds <da...@gmail.com>
>
>> On 10/04/12 16:09, Andrés Zules wrote:
>>
>>  2012/4/10 Dave Reynolds<da...@gmail.com>
>>> >
>>>
>>
>>  Are you sure that was the query you ran?
>>>> Or alternatively are you sure that was the ontology you ran it over?
>>>>
>>>
>>>
>>>  The only inverse of pizza:isToppingOf is pizza:hasTopping so you are
>>>> effectively asking the query:
>>>>
>>>>     ?pizza pizza:hasTopping pizza:MushroomTopping .
>>>>
>>>> Which should return empty for that ontology.
>>>>
>>>>
>>> Yes, I am sure. But it's strange I run without reasoner:
>>>
>>> SELECT ?NombrePizza
>>> WHERE {
>>>  ?NombrePizza pizza:isToppingOf pizza:MushroomTopping .
>>> }
>>>
>>> And the result is empty, but with (without reasoner):
>>>
>>> SELECT ?NombrePizza
>>> WHERE {
>>>  ?NombrePizza ?Relacion pizza:MushroomTopping .
>>>  ?Relacion owl:inverseOf pizza:isToppingOf .
>>> }
>>>
>>> The result is
>>>
>>>  DefaultOWLNamedClass(
>>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**FourSeasons<http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons>
>>> )
>>> DefaultOWLNamedClass(
>>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**Mushroom<http://www.co-ode.org/ontologies/pizza/pizza.owl#Mushroom>
>>> )
>>> DefaultOWLNamedClass(
>>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**Giardiniera<http://www.co-ode.org/ontologies/pizza/pizza.owl#Giardiniera>
>>> )
>>> DefaultOWLNamedClass(
>>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**LaReine<http://www.co-ode.org/ontologies/pizza/pizza.owl#LaReine>
>>> )
>>>
>>
>> That sounds like a bug somewhere. As far as I can see the only inverseOf
>> pizza:isToppingOf is pizza:hasTopping and the only mentions of hasTopping
>> are as class restrictions.
>>
>> I can't see how the query should return anything *with* inference, let
>> along without inference!
>>
>>  The Ontology models both pizzas and toppings as classes and there is no
>>>> pizza:hasTopping relationship between the classes. Each of the Pizza
>>>> classes like FourSeasons are defined via:
>>>>
>>>>    <owl:Class rdf:about="#FourSeasons">
>>>>        <rdfs:label xml:lang="pt">QuatroQueijos</****rdfs:label>
>>>>
>>>>        <rdfs:subClassOf>
>>>>            <owl:Restriction>
>>>>                <owl:onProperty rdf:resource="#hasTopping"/>
>>>>                <owl:someValuesFrom rdf:resource="#****
>>>> MushroomTopping"/>
>>>>
>>>>            </owl:Restriction>
>>>>        </rdfs:subClassOf>
>>>>    ...
>>>>
>>>> So an instance of FourSeasons would have an instance of a
>>>> MushroomTopping
>>>> on, which is the not the same as your query and the ontology has no such
>>>> instances anyway.
>>>>
>>>> In any case to do anything useful with that ontology you really need a
>>>> full DL reasoner such as Pellet.
>>>>
>>>> Dave
>>>>
>>>>
>>> Thanks Dave. I dont know why my query's result is 4 classes, i am
>>> beginner
>>> with the SPARQL and execute that statement testing many others, do you
>>> have
>>> a alternative query? I only want pizzas with Mushrooms.
>>>
>>
>> Well that ontology is a bit painful to work with at the SPARQL level but
>> you could query for (untested example):
>>
>> SELECT * WHERE
>> {
>>    ?pizza rdfs:subClassof [
>>        owl:onProperty pizza:hasTopping;
>>        owl:someValuesFrom pizza:MushroomTopping ] .
>> }
>>
>> Dave
>>
>
> Thanks Dave ... I realize on protege and jena this query:
>
> SELECT *
> WHERE {
> ?X ?Y pizza:MushroomTopping  .
> }
>
> See outputs
>
> https://plus.google.com/photos/116190906023059719803/albums/5730984081208355185
>
> I infer that
>
> | _:b2                   | owl:someValuesFrom
>     |
> | _:b5                   | owl:someValuesFrom
>     |
> | _:b6                   | owl:someValuesFrom
>     |
> | _:b7                   | owl:someValuesFrom
>     |
>
> and
>
>  DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons)
> DefaultOWLObjectProperty(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping) etc etc etc
>
> are the pizzas with MushroomTopping
>
> Why does Jena return _:b* and no return the names? I dont understan why
> the results have differences
>
> Do you have some idea?
>
> - - -
> Fabricio Andrés Zules Acosta
>



-- 
- - -
Fabricio Andrés Zules Acosta

Re: Simple Pizza Query

Posted by Dave Reynolds <da...@gmail.com>.
On 15/04/12 18:37, Andrés Zules wrote:

> Thanks Dave. I understand  "_:b" now, also you are right. The query isn't
> correct. I write a new query:
>
> PREFIX pizza:<http://www.co-ode.org/ontologies/pizza/pizza.owl#>
>> PREFIX owl:<http://www.w3.org/2002/07/owl#>
>> PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
>> SELECT *
>> FROM<http://www.co-ode.org/ontologies/pizza/pizza.owl#>
>> WHERE {
>>   ?Y rdfs:subClassOf ?X .
>>   ?X owl:someValuesFrom pizza:MushroomTopping
>> }
>
>
> The query's result from sparqler --- http://sparql.org/sparql.html
> and from protege are the same but from jena the results are many more, I
> think that the Reasoner produces extra results.
>
> https://lh6.googleusercontent.com/-CPGT22JYut8/T4sFV5J3sJI/AAAAAAAAAKo/vCaOBS0tBdk/s903/PizzaQuery.png

Yes, the jena rule reasoner is an OWL/full reasoner so it treats these 
owl:Restrictions as classes and reasons with them as well.

For your query run without inference.

Dave

Re: Simple Pizza Query

Posted by Andrés Zules <fa...@gmail.com>.
2012/4/15 Dave Reynolds <da...@gmail.com>

> On 13/04/12 21:36, Andrés Zules wrote:
>
>> 2012/4/10 Dave Reynolds<da...@gmail.com>
>> >
>>
>>  On 10/04/12 16:09, Andrés Zules wrote:
>>>
>>>  2012/4/10 Dave Reynolds<dave.e.reynolds@**gma**il.com<http://gmail.com>
>>> <dave.e.reynolds@gmail.**com <da...@gmail.com>>
>>>
>>
>  Well that ontology is a bit painful to work with at the SPARQL level but
>>> you could query for (untested example):
>>>
>>> SELECT * WHERE
>>> {
>>>    ?pizza rdfs:subClassof [
>>>        owl:onProperty pizza:hasTopping;
>>>        owl:someValuesFrom pizza:MushroomTopping ] .
>>> }
>>>
>>> Dave
>>>
>>>
>> Thanks Dave ... I realize on protege and jena this query:
>>
>> SELECT *
>> WHERE {
>> ?X ?Y pizza:MushroomTopping  .
>> }
>>
>> See outputs
>> https://plus.google.com/**photos/116190906023059719803/**
>> albums/5730984081208355185<https://plus.google.com/photos/116190906023059719803/albums/5730984081208355185>
>>
>
> Like I say, for that ontology as I see it when I download it then there
> should not be any matches for the query with ?Y = pizza:hasTopping.
>
>
>  I infer that
>>
>> | _:b2                   | owl:someValuesFrom
>>   |
>> | _:b5                   | owl:someValuesFrom
>>   |
>> | _:b6                   | owl:someValuesFrom
>>   |
>> | _:b7                   | owl:someValuesFrom
>>   |
>>
>> and
>>
>>  DefaultOWLNamedClass(
>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**FourSeasons<http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons>
>> )
>> DefaultOWLObjectProperty(
>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**hasTopping<http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping>)
>> etc etc etc
>>
>> are the pizzas with MushroomTopping
>>
>> Why does Jena return _:b* and no return the names? I dont understan why
>> the
>> results have differences
>>
>
> If you look at the declarations of the relevant Named Classes you see
> things like:
>
>
> <owl:Class rdf:about="#FourSeasons">
>  <rdfs:label xml:lang="pt">QuatroQueijos</**rdfs:label>
>
>  <rdfs:subClassOf>
>    <owl:Restriction>
>      <owl:onProperty rdf:resource="#hasTopping"/>
>      <owl:someValuesFrom rdf:resource="#**MushroomTopping"/>
>
>    </owl:Restriction>
>  </rdfs:subClassOf>
>  ...
>
> Putting that in Turtle to make in clearer:
>
>  pizza:FourSeasons a owl:Class;
>    rdfs:label "QuatroQueijos"@pt;
>    rdfs:subClassOf [
>      a owl:Restriction;
>      owl:onProperty pizza:hasTopping;
>      owl:someValuesFrom pizza:MushroomTopping;
>    ]
>    ...
>
> So each OWL restriction is represented by a blank-node (an RDF resource
> which has no URI). If we want to write that out as a set of separate
> triples then you see:
>
>  pizza:FourSeasons a owl:Class .
>  pizza:FourSeasons rdfs:label "QuatroQueijos"@pt .
>  pizza:FourSeasons rdfs:subClassOf _:b .
>
>  _:b  a owl:Restriction .
>  _:b  owl:onProperty pizza:hasTopping .
>  _:b  owl:someValuesFrom pizza:MushroomTopping .
>
> The notation _:X is what Turtle uses to represent such blank nodes, which
> is what you are seeing in Jena's output.
>
> So all that's happening is that your query is matching the
> owl:someValuesFrom part of those restrictions, i.e. the final triple in the
> above example.  Hence my suggested query quoted above.
>
> Dave
>


Thanks Dave. I understand  "_:b" now, also you are right. The query isn't
correct. I write a new query:

PREFIX pizza:<http://www.co-ode.org/ontologies/pizza/pizza.owl#>
> PREFIX owl:<http://www.w3.org/2002/07/owl#>
> PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
> SELECT *
> FROM <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
> WHERE {
>  ?Y rdfs:subClassOf ?X .
>  ?X owl:someValuesFrom pizza:MushroomTopping
> }


The query's result from sparqler --- http://sparql.org/sparql.html
and from protege are the same but from jena the results are many more, I
think that the Reasoner produces extra results.

https://lh6.googleusercontent.com/-CPGT22JYut8/T4sFV5J3sJI/AAAAAAAAAKo/vCaOBS0tBdk/s903/PizzaQuery.png

I learn too much with your help. Thank you very much.

- - -
Andrés

Re: Simple Pizza Query

Posted by Dave Reynolds <da...@gmail.com>.
On 13/04/12 21:36, Andrés Zules wrote:
> 2012/4/10 Dave Reynolds<da...@gmail.com>
>
>> On 10/04/12 16:09, Andrés Zules wrote:
>>
>>   2012/4/10 Dave Reynolds<da...@gmail.com>

>> Well that ontology is a bit painful to work with at the SPARQL level but
>> you could query for (untested example):
>>
>> SELECT * WHERE
>> {
>>     ?pizza rdfs:subClassof [
>>         owl:onProperty pizza:hasTopping;
>>         owl:someValuesFrom pizza:MushroomTopping ] .
>> }
>>
>> Dave
>>
>
> Thanks Dave ... I realize on protege and jena this query:
>
> SELECT *
> WHERE {
> ?X ?Y pizza:MushroomTopping  .
> }
>
> See outputs
> https://plus.google.com/photos/116190906023059719803/albums/5730984081208355185

Like I say, for that ontology as I see it when I download it then there 
should not be any matches for the query with ?Y = pizza:hasTopping.

> I infer that
>
> | _:b2                   | owl:someValuesFrom
>    |
> | _:b5                   | owl:someValuesFrom
>    |
> | _:b6                   | owl:someValuesFrom
>    |
> | _:b7                   | owl:someValuesFrom
>    |
>
> and
>
>   DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons)
> DefaultOWLObjectProperty(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping) etc etc etc
>
> are the pizzas with MushroomTopping
>
> Why does Jena return _:b* and no return the names? I dont understan why the
> results have differences

If you look at the declarations of the relevant Named Classes you see 
things like:

<owl:Class rdf:about="#FourSeasons">
   <rdfs:label xml:lang="pt">QuatroQueijos</rdfs:label>
   <rdfs:subClassOf>
     <owl:Restriction>
       <owl:onProperty rdf:resource="#hasTopping"/>
       <owl:someValuesFrom rdf:resource="#MushroomTopping"/>
     </owl:Restriction>
   </rdfs:subClassOf>
   ...

Putting that in Turtle to make in clearer:

   pizza:FourSeasons a owl:Class;
     rdfs:label "QuatroQueijos"@pt;
     rdfs:subClassOf [
       a owl:Restriction;
       owl:onProperty pizza:hasTopping;
       owl:someValuesFrom pizza:MushroomTopping;
     ]
     ...

So each OWL restriction is represented by a blank-node (an RDF resource 
which has no URI). If we want to write that out as a set of separate 
triples then you see:

   pizza:FourSeasons a owl:Class .
   pizza:FourSeasons rdfs:label "QuatroQueijos"@pt .
   pizza:FourSeasons rdfs:subClassOf _:b .

   _:b  a owl:Restriction .
   _:b  owl:onProperty pizza:hasTopping .
   _:b  owl:someValuesFrom pizza:MushroomTopping .

The notation _:X is what Turtle uses to represent such blank nodes, 
which is what you are seeing in Jena's output.

So all that's happening is that your query is matching the 
owl:someValuesFrom part of those restrictions, i.e. the final triple in 
the above example.  Hence my suggested query quoted above.

Dave

Re: Simple Pizza Query

Posted by Andrés Zules <fa...@gmail.com>.
2012/4/10 Dave Reynolds <da...@gmail.com>

> On 10/04/12 16:09, Andrés Zules wrote:
>
>  2012/4/10 Dave Reynolds<da...@gmail.com>
>> >
>>
>
>  Are you sure that was the query you ran?
>>> Or alternatively are you sure that was the ontology you ran it over?
>>>
>>
>>
>>  The only inverse of pizza:isToppingOf is pizza:hasTopping so you are
>>> effectively asking the query:
>>>
>>>     ?pizza pizza:hasTopping pizza:MushroomTopping .
>>>
>>> Which should return empty for that ontology.
>>>
>>>
>> Yes, I am sure. But it's strange I run without reasoner:
>>
>> SELECT ?NombrePizza
>> WHERE {
>>  ?NombrePizza pizza:isToppingOf pizza:MushroomTopping .
>> }
>>
>> And the result is empty, but with (without reasoner):
>>
>> SELECT ?NombrePizza
>> WHERE {
>>  ?NombrePizza ?Relacion pizza:MushroomTopping .
>>  ?Relacion owl:inverseOf pizza:isToppingOf .
>> }
>>
>> The result is
>>
>>  DefaultOWLNamedClass(
>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**FourSeasons<http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons>
>> )
>> DefaultOWLNamedClass(
>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**Mushroom<http://www.co-ode.org/ontologies/pizza/pizza.owl#Mushroom>
>> )
>> DefaultOWLNamedClass(
>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**Giardiniera<http://www.co-ode.org/ontologies/pizza/pizza.owl#Giardiniera>
>> )
>> DefaultOWLNamedClass(
>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**LaReine<http://www.co-ode.org/ontologies/pizza/pizza.owl#LaReine>
>> )
>>
>
> That sounds like a bug somewhere. As far as I can see the only inverseOf
> pizza:isToppingOf is pizza:hasTopping and the only mentions of hasTopping
> are as class restrictions.
>
> I can't see how the query should return anything *with* inference, let
> along without inference!
>
>  The Ontology models both pizzas and toppings as classes and there is no
>>> pizza:hasTopping relationship between the classes. Each of the Pizza
>>> classes like FourSeasons are defined via:
>>>
>>>    <owl:Class rdf:about="#FourSeasons">
>>>        <rdfs:label xml:lang="pt">QuatroQueijos</****rdfs:label>
>>>
>>>        <rdfs:subClassOf>
>>>            <owl:Restriction>
>>>                <owl:onProperty rdf:resource="#hasTopping"/>
>>>                <owl:someValuesFrom rdf:resource="#****MushroomTopping"/>
>>>
>>>            </owl:Restriction>
>>>        </rdfs:subClassOf>
>>>    ...
>>>
>>> So an instance of FourSeasons would have an instance of a MushroomTopping
>>> on, which is the not the same as your query and the ontology has no such
>>> instances anyway.
>>>
>>> In any case to do anything useful with that ontology you really need a
>>> full DL reasoner such as Pellet.
>>>
>>> Dave
>>>
>>>
>> Thanks Dave. I dont know why my query's result is 4 classes, i am beginner
>> with the SPARQL and execute that statement testing many others, do you
>> have
>> a alternative query? I only want pizzas with Mushrooms.
>>
>
> Well that ontology is a bit painful to work with at the SPARQL level but
> you could query for (untested example):
>
> SELECT * WHERE
> {
>    ?pizza rdfs:subClassof [
>        owl:onProperty pizza:hasTopping;
>        owl:someValuesFrom pizza:MushroomTopping ] .
> }
>
> Dave
>

Thanks Dave ... I realize on protege and jena this query:

SELECT *
WHERE {
?X ?Y pizza:MushroomTopping  .
}

See outputs
https://plus.google.com/photos/116190906023059719803/albums/5730984081208355185

I infer that

| _:b2                   | owl:someValuesFrom
  |
| _:b5                   | owl:someValuesFrom
  |
| _:b6                   | owl:someValuesFrom
  |
| _:b7                   | owl:someValuesFrom
  |

and

 DefaultOWLNamedClass(
http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons)
DefaultOWLObjectProperty(
http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping) etc etc etc

are the pizzas with MushroomTopping

Why does Jena return _:b* and no return the names? I dont understan why the
results have differences

Do you have some idea?

- - -
Fabricio Andrés Zules Acosta

Re: Simple Pizza Query

Posted by Dave Reynolds <da...@gmail.com>.
On 10/04/12 16:09, Andrés Zules wrote:
> 2012/4/10 Dave Reynolds<da...@gmail.com>

>> Are you sure that was the query you ran?
>> Or alternatively are you sure that was the ontology you ran it over?
>
>
>> The only inverse of pizza:isToppingOf is pizza:hasTopping so you are
>> effectively asking the query:
>>
>>      ?pizza pizza:hasTopping pizza:MushroomTopping .
>>
>> Which should return empty for that ontology.
>>
>
> Yes, I am sure. But it's strange I run without reasoner:
>
> SELECT ?NombrePizza
> WHERE {
>   ?NombrePizza pizza:isToppingOf pizza:MushroomTopping .
> }
>
> And the result is empty, but with (without reasoner):
>
> SELECT ?NombrePizza
> WHERE {
>   ?NombrePizza ?Relacion pizza:MushroomTopping .
>   ?Relacion owl:inverseOf pizza:isToppingOf .
> }
>
> The result is
>
>   DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons)
> DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#Mushroom)
> DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#Giardiniera)
> DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#LaReine)

That sounds like a bug somewhere. As far as I can see the only inverseOf 
pizza:isToppingOf is pizza:hasTopping and the only mentions of 
hasTopping are as class restrictions.

I can't see how the query should return anything *with* inference, let 
along without inference!

>> The Ontology models both pizzas and toppings as classes and there is no
>> pizza:hasTopping relationship between the classes. Each of the Pizza
>> classes like FourSeasons are defined via:
>>
>>     <owl:Class rdf:about="#FourSeasons">
>>         <rdfs:label xml:lang="pt">QuatroQueijos</**rdfs:label>
>>         <rdfs:subClassOf>
>>             <owl:Restriction>
>>                 <owl:onProperty rdf:resource="#hasTopping"/>
>>                 <owl:someValuesFrom rdf:resource="#**MushroomTopping"/>
>>             </owl:Restriction>
>>         </rdfs:subClassOf>
>>     ...
>>
>> So an instance of FourSeasons would have an instance of a MushroomTopping
>> on, which is the not the same as your query and the ontology has no such
>> instances anyway.
>>
>> In any case to do anything useful with that ontology you really need a
>> full DL reasoner such as Pellet.
>>
>> Dave
>>
>
> Thanks Dave. I dont know why my query's result is 4 classes, i am beginner
> with the SPARQL and execute that statement testing many others, do you have
> a alternative query? I only want pizzas with Mushrooms.

Well that ontology is a bit painful to work with at the SPARQL level but 
you could query for (untested example):

SELECT * WHERE
{
     ?pizza rdfs:subClassof [
         owl:onProperty pizza:hasTopping;
         owl:someValuesFrom pizza:MushroomTopping ] .
}

Dave

Re: Simple Pizza Query

Posted by Andrés Zules <fa...@gmail.com>.
2012/4/10 Dave Reynolds <da...@gmail.com>

> On 10/04/12 01:58, Andrés Zules wrote:
>
>> Hi everyone
>>
>> I use Protege Version 3.4.7 (Build 620) and execute a simple query in the
>> SPARQL Query Panel on http://www.co-ode.org/**ontologies/pizza/pizza.owl<http://www.co-ode.org/ontologies/pizza/pizza.owl>
>> :
>>
>> SELECT ?NombrePizza
>>
>>> WHERE {
>>>  ?NombrePizza ?Relacion pizza:MushroomTopping .
>>>  ?Relacion owl:inverseOf pizza:isToppingOf .
>>> }
>>>
>>
>>
>> The result is 4 pizzas:
>>
>>  DefaultOWLNamedClass(
>>
>>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**FourSeasons<http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons>
>>> )
>>>
>>
>>   DefaultOWLNamedClass(
>>
>>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**Mushroom<http://www.co-ode.org/ontologies/pizza/pizza.owl#Mushroom>
>>> )
>>>
>>
>>   DefaultOWLNamedClass(
>>
>>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**Giardiniera<http://www.co-ode.org/ontologies/pizza/pizza.owl#Giardiniera>
>>> )
>>>
>>
>>   DefaultOWLNamedClass(
>>
>>> http://www.co-ode.org/**ontologies/pizza/pizza.owl#**LaReine<http://www.co-ode.org/ontologies/pizza/pizza.owl#LaReine>
>>> )
>>>
>>
> Are you sure that was the query you ran?
> Or alternatively are you sure that was the ontology you ran it over?


> The only inverse of pizza:isToppingOf is pizza:hasTopping so you are
> effectively asking the query:
>
>     ?pizza pizza:hasTopping pizza:MushroomTopping .
>
> Which should return empty for that ontology.
>

Yes, I am sure. But it's strange I run without reasoner:

SELECT ?NombrePizza
WHERE {
 ?NombrePizza pizza:isToppingOf pizza:MushroomTopping .
}

And the result is empty, but with (without reasoner):

SELECT ?NombrePizza
WHERE {
 ?NombrePizza ?Relacion pizza:MushroomTopping .
 ?Relacion owl:inverseOf pizza:isToppingOf .
}

The result is

 DefaultOWLNamedClass(
http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons)
DefaultOWLNamedClass(
http://www.co-ode.org/ontologies/pizza/pizza.owl#Mushroom)
DefaultOWLNamedClass(
http://www.co-ode.org/ontologies/pizza/pizza.owl#Giardiniera)
DefaultOWLNamedClass(
http://www.co-ode.org/ontologies/pizza/pizza.owl#LaReine)


> The Ontology models both pizzas and toppings as classes and there is no
> pizza:hasTopping relationship between the classes. Each of the Pizza
> classes like FourSeasons are defined via:
>
>    <owl:Class rdf:about="#FourSeasons">
>        <rdfs:label xml:lang="pt">QuatroQueijos</**rdfs:label>
>        <rdfs:subClassOf>
>            <owl:Restriction>
>                <owl:onProperty rdf:resource="#hasTopping"/>
>                <owl:someValuesFrom rdf:resource="#**MushroomTopping"/>
>            </owl:Restriction>
>        </rdfs:subClassOf>
>    ...
>
> So an instance of FourSeasons would have an instance of a MushroomTopping
> on, which is the not the same as your query and the ontology has no such
> instances anyway.
>
> In any case to do anything useful with that ontology you really need a
> full DL reasoner such as Pellet.
>
> Dave
>

Thanks Dave. I dont know why my query's result is 4 classes, i am beginner
with the SPARQL and execute that statement testing many others, do you have
a alternative query? I only want pizzas with Mushrooms.

- - -
Fabricio

Re: Simple Pizza Query

Posted by Dave Reynolds <da...@gmail.com>.
On 10/04/12 01:58, Andrés Zules wrote:
> Hi everyone
>
> I use Protege Version 3.4.7 (Build 620) and execute a simple query in the
> SPARQL Query Panel on http://www.co-ode.org/ontologies/pizza/pizza.owl:
>
> SELECT ?NombrePizza
>> WHERE {
>>   ?NombrePizza ?Relacion pizza:MushroomTopping .
>>   ?Relacion owl:inverseOf pizza:isToppingOf .
>> }
>
>
> The result is 4 pizzas:
>
>   DefaultOWLNamedClass(
>> http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons)
>
>    DefaultOWLNamedClass(
>> http://www.co-ode.org/ontologies/pizza/pizza.owl#Mushroom)
>
>    DefaultOWLNamedClass(
>> http://www.co-ode.org/ontologies/pizza/pizza.owl#Giardiniera)
>
>    DefaultOWLNamedClass(
>> http://www.co-ode.org/ontologies/pizza/pizza.owl#LaReine)

Are you sure that was the query you ran?
Or alternatively are you sure that was the ontology you ran it over?

The only inverse of pizza:isToppingOf is pizza:hasTopping so you are 
effectively asking the query:

      ?pizza pizza:hasTopping pizza:MushroomTopping .

Which should return empty for that ontology.

The Ontology models both pizzas and toppings as classes and there is no 
pizza:hasTopping relationship between the classes. Each of the Pizza 
classes like FourSeasons are defined via:

     <owl:Class rdf:about="#FourSeasons">
         <rdfs:label xml:lang="pt">QuatroQueijos</rdfs:label>
         <rdfs:subClassOf>
             <owl:Restriction>
                 <owl:onProperty rdf:resource="#hasTopping"/>
                 <owl:someValuesFrom rdf:resource="#MushroomTopping"/>
             </owl:Restriction>
         </rdfs:subClassOf>
     ...

So an instance of FourSeasons would have an instance of a 
MushroomTopping on, which is the not the same as your query and the 
ontology has no such instances anyway.

In any case to do anything useful with that ontology you really need a 
full DL reasoner such as Pellet.

Dave