W3C home > Mailing lists > Public > public-sparql-dev@w3.org > April to June 2009

Re: Sparql query help

From: Samuel Pedro <samuelcpspam@gmail.com>
Date: Sat, 13 Jun 2009 19:21:52 +0100
Message-ID: <cc48d5440906131121w4c0d23b0ic3687360503fa89a@mail.gmail.com>
To: Paul Gearon <gearon@ieee.org>
Cc: public-sparql-dev@w3.org
I changed the ontology, have now this class,

<owl:Class rdf:ID="ChickenWithOnions">
    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
    >Chicken With Onions</rdfs:label>
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:someValuesFrom rdf:resource="#Onion"/>
        <owl:onProperty rdf:resource="#hasIngridients"/>
      </owl:Restriction>
    </rdfs:subClassOf>
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:onProperty rdf:resource="#hasIngridients"/>
        <owl:someValuesFrom rdf:resource="#Chicken"/>
      </owl:Restriction>
    </rdfs:subClassOf>
    <rdfs:subClassOf>
      <owl:Class rdf:about="#Plates"/>
    </rdfs:subClassOf>
  </owl:Class>

If i want to know which ingredients have the plate "Chicken with Onions"?
Shouldn´t be...

PREFIX owl:<http://www.w3.org/2002/07/owl#>
PREFIX plate:<http://www.owl-ontologies.com/testFood2.owl#">
SELECT ?ingredients

WHERE { ?ingredients owl:someValuesFrom plate:ChickenWithTomato } --> (how
do you read this?)

what's wrong this time?

2009/6/12 Paul Gearon <gearon@ieee.org>

> On Fri, Jun 12, 2009 at 1:31 PM, Samuel Pedro<samuelcpspam@gmail.com>
> wrote:
> > So i can only do queries using properties like owl:sameAS,
> :differentFrom,
> > :subClass, transitive..... to object like  rdfs:label, and... ?x  ????
>
> No, there is no restriction of this type.
>
> > I have this class in the ontology,that have the property someValues can i
> do
> > a query that ask wich are the ingredients that "ChickenWithOnions" have?
> >
> > <owl:Class rdf:ID="ChickenWithOnions">
> >     <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
> >     >Chicken With Onions</rdfs:label> (add the label)
> >     <rdfs:subClassOf rdf:resource="#Plates"/>
> >     <rdfs:subClassOf>
> >       <owl:Restriction>
> >         <owl:onProperty rdf:resource="#hasIngridients"/>
> >         <owl:someValuesFrom>
> >           <owl:Class>
> >             <owl:intersectionOf rdf:parseType="Collection">
> >               <owl:Class rdf:about="#Chicken"/>
> >               <owl:Class rdf:about="#Onion"/>
> >             </owl:intersectionOf>
> >           </owl:Class>
> >         </owl:someValuesFrom>
> >       </owl:Restriction>
> >     </rdfs:subClassOf>
> >   </owl:Class>
>
> This model isn't doing what you think it is. It says that some of the
> ingredients come from something that is both a chicken and an onion. I
> know that Monsanto have been doing some rather avant-garde research
> into genetic engineering of food, but I think they have still come
> short of this.
>
> What I think you were looking for was a Plate that is a subclass of
> the intersection of "things with some ingredients that are chicken"
> and "things with some ingredients that are onion".
>
> > the query should be this... (wrong tried and nothing, i'm doing again the
> > same mistake right?)
> >
> > SELECT ?plate ?ingredient
> > WHERE {
> >  ?plate owl:hasIngridients ?ingredient.
> >  ?plate rdfs:label "Chicken With Onions" .
> > }
> >
> > so the only property that i can use is the ones that says "rdfs:...."
> ???
>
> Not at all. It's just that the data didn't say what you thought it
> did. Also, there is no "hasIngredients" predicate in the OWL
> namespace. Perhaps you should define it as food:hasIngredients.
>
> Actually, queries are a pretty good way to find what you want, without
> needing to define plates of "Chicken with Onions".
>
> SELECT ?plate ?ingredient
> WHERE {
>  ?plate food:hasIngredients ?ingredient .
>  ?plate food:hasIngredients food:Chicken .
>  ?plate food:hasIngredients food:Onion .
> }
>
> This will return a list of all the plates and their ingredients, where
> the plates are restricted to only those that have both Chicken and
> Onion in their ingredients. Of course, both Chicken and Onion will
> show up in the list for each plate, as will all of the other
> ingredients.
>
> Regards,
> Paul
>

-- 
--
Samuel Pedro
Received on Saturday, 13 June 2009 18:22:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 13 June 2009 18:22:30 GMT