- From: Samuel Pedro <samuelcpspam@gmail.com>
- Date: Fri, 12 Jun 2009 19:31:22 +0100
- To: public-sparql-dev@w3.org
- Message-ID: <cc48d5440906121131w13c2069du3f0b145de64b0632@mail.gmail.com>
So i can only do queries using properties like owl:sameAS, :differentFrom, :subClass, transitive..... to object like rdfs:label, and... ?x ???? 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> 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:...." ??? 2009/6/12 Dau, Frithjof <frithjof.dau@sap.com> Hi Samuel, > > with SPARQL you can essentially query subgraphs of a given graph. In your > "OWL-graph", you have a node "...#Meat". With SPARQL, you can query other > nodes and the properties which relate these nodes to you "...#Meat"-node. > Anyhow, the only property which relates your "...#Meat"-node to ther nodes > is the "rdfs:subClassOf"-property, relating your "...#Meat"-node to its > super- and subclasses (depending on whether your "...#Meat"-node is the > subject or object of a (x rdfs:subClassOf y) triple). > > I guess what you have in mind is something like: The class is called > "Meat", so let's query for that name. Nope, does not work. The name of the > class is a part of the node-URI, and you cannot query parts of these -let's > say- URI-string. So, if you want to query classes by its names, you *must* > make the name in the ontology explicit by using a property. The most common > approach is the "rdfs:label"-attribute. Iy you use it -and you do it for > your "...#Pig"-class, you explicitely relate the name "Pig" (a literal) to > the class by the rdfs:label-property. Now you have the situation that the > class is linked to its name by use of nodes and properties, and thus you can > query it. > > I sugges you have a look at your ontology with an RDF-visualizer (like > IsaViz), keep in mind that you can only query for graph patterns, and then > you will hopefully understand why your initial query does not work. > > Cheers > Frithjof > > ------------------------------ > *Von:* public-sparql-dev-request@w3.org [mailto: > public-sparql-dev-request@w3.org] *Im Auftrag von *Samuel Pedro > *Gesendet:* Freitag, 12. Juni 2009 17:35 > *An:* Stephane Corlosquet; Lee Feigenbaum; public-sparql-dev@w3.org > *Betreff:* Re: Sparql query help > > Ok, tried to send as a attachment but probably something went wrong, i will > post here: > > <?xml version="1.0"?> > <rdf:RDF > xmlns:xsp="http://www.owl-ontologies.com/2005/08/07/xsp.owl#" > xmlns="http://www.owl-ontologies.com/testFood2.owl#" > xmlns:swrlb="http://www.w3.org/2003/11/swrlb#" > xmlns:swrl="http://www.w3.org/2003/11/swrl#" > xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#" > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > xmlns:xsd="http://www.w3.org/2001/XMLSchema#" > xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > xmlns:owl="http://www.w3.org/2002/07/owl#" > xml:base="http://www.owl-ontologies.com/testFood2.owl"> > <owl:Ontology rdf:about=""/> > <owl:Class rdf:ID="Cow"> > <rdfs:subClassOf> > <owl:Class rdf:ID="RedMeat"/> > </rdfs:subClassOf> > </owl:Class> > <owl:Class rdf:ID="Chicken"> > <rdfs:subClassOf> > <owl:Class rdf:ID="WhiteMeat"/> > </rdfs:subClassOf> > </owl:Class> > <owl:Class rdf:ID="Pig2"> > <owl:equivalentClass> > <owl:Class rdf:ID="Pig"/> > </owl:equivalentClass> > <rdfs:subClassOf> > <owl:Class rdf:about="#RedMeat"/> > </rdfs:subClassOf> > <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string" > >Pig2</rdfs:label> > </owl:Class> > <owl:Class rdf:ID="Onion"> > <rdfs:subClassOf> > <owl:Class rdf:ID="Vegetable"/> > </rdfs:subClassOf> > </owl:Class> > <owl:Class rdf:ID="Ingredients"/> > <owl:Class rdf:about="#Pig"> > <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string" > >Pig</rdfs:label> > <rdfs:subClassOf> > <owl:Class rdf:about="#RedMeat"/> > </rdfs:subClassOf> > <owl:equivalentClass rdf:resource="#Pig2"/> > </owl:Class> > <owl:Class rdf:ID="ChickenWithTomato"> > <rdfs:subClassOf> > <owl:Class rdf:ID="Plates"/> > </rdfs:subClassOf> > <rdfs:subClassOf> > <owl:Restriction> > <owl:onProperty> > <owl:ObjectProperty rdf:ID="hasIngridients"/> > </owl:onProperty> > <owl:someValuesFrom> > <owl:Class> > <owl:intersectionOf rdf:parseType="Collection"> > <owl:Class rdf:about="#Chicken"/> > <owl:Class rdf:ID="Tomato"/> > </owl:intersectionOf> > </owl:Class> > </owl:someValuesFrom> > </owl:Restriction> > </rdfs:subClassOf> > </owl:Class> > <owl:Class rdf:ID="ChickenWithOnions"> > <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> > <owl:Class rdf:about="#WhiteMeat"> > <rdfs:subClassOf> > <owl:Class rdf:ID="Meat"/> > </rdfs:subClassOf> > </owl:Class> > <owl:Class rdf:about="#Tomato"> > <rdfs:subClassOf> > <owl:Class rdf:about="#Vegetable"/> > </rdfs:subClassOf> > </owl:Class> > <owl:Class rdf:about="#RedMeat"> > <rdfs:subClassOf> > <owl:Class rdf:about="#Meat"/> > </rdfs:subClassOf> > </owl:Class> > <owl:Class rdf:about="#Vegetable"> > <rdfs:subClassOf rdf:resource="#Ingredients"/> > </owl:Class> > <owl:Class rdf:about="#Meat"> > <rdfs:subClassOf rdf:resource="#Ingredients"/> > </owl:Class> > <owl:ObjectProperty rdf:ID="hasChicken"> > <rdfs:subPropertyOf> > <owl:ObjectProperty rdf:ID="hasWhiteMeat"/> > </rdfs:subPropertyOf> > </owl:ObjectProperty> > <owl:ObjectProperty rdf:ID="hasMeat"> > <rdfs:subPropertyOf rdf:resource="#hasIngridients"/> > </owl:ObjectProperty> > <owl:ObjectProperty rdf:ID="hasVegetable"> > <rdfs:subPropertyOf rdf:resource="#hasIngridients"/> > </owl:ObjectProperty> > <owl:ObjectProperty rdf:ID="hasIngridients_26"> > <rdfs:subPropertyOf rdf:resource="#hasIngridients"/> > </owl:ObjectProperty> > <owl:ObjectProperty rdf:ID="hasOnion"> > <rdfs:subPropertyOf rdf:resource="#hasVegetable"/> > </owl:ObjectProperty> > <owl:ObjectProperty rdf:about="#hasWhiteMeat"> > <rdfs:subPropertyOf rdf:resource="#hasMeat"/> > </owl:ObjectProperty> > </rdf:RDF> > > > But think that i understand why it cant work that way. > > "but I think it's pretty likely that your classes are resources (URIs)" how > i know that? > > > 2009/6/12 Stephane Corlosquet <scorlosquet@gmail.com> > >> Hi Samuel, >> >> You cannot use ?meatClass owl:Class "Pig" in your WHERE clause because it >> is not a valid pattern. You should follow the {subject property object} >> pattern in your WHERE clause. owl:Class is a class and not a property. >> >> Stephane. >> >> >> On Fri, Jun 12, 2009 at 3:52 PM, Samuel Pedro <samuelcpspam@gmail.com>wrote: >> >>> This is my owl file, i had to add labels to the classes, and do this: >>> >>> SELECT ?equivalentClass ?meatClass >>> WHERE { >>> ?equivalentClass owl:equivalentClass ?meatClass . >>> ?meatClass rdfs:label "Pig" . (in owl file i have Pig and Pig2) >>> } >>> >>> and why this query doesnt work, why it only works for labels? (I'm trying >>> to understand sparql but...) >>> >>> SELECT ?equivalentClass ?meatClass >>> WHERE { >>> ?equivalentClass owl:equivalentClass ?meatClass . >>> ?meatClass owl:Class "Pig" . >>> } >>> >>> >>> >>> 2009/6/12 Lee Feigenbaum <lee@thefigtrees.net> >>> >>> Samuel Pedro wrote: >>>> >>>>> Im trying to do this query... >>>>> >>>>> SELECT ?subject ?object >>>>> WHERE { ?subject owl:equivalenteClass ?object FILTER( ?object = "Meat") >>>>> } >>>>> >>>>> im trying to find the equivalente Class of meat, but it doesn't return >>>>> what i want, what am i doing wrong? >>>>> >>>>> if i do this... >>>>> >>>>> SELECT ?subject ?object >>>>> WHERE { ?subject owl:equivalenteClass ?object FILTER( ?object != >>>>> "Meat") } >>>>> >>>>> i get all the equivalent class that there is in the owl. why? >>>>> >>>> >>>> Without seeing your data, it's hard to say for sure, but I think it's >>>> pretty likely that your classes are resources (URIs) and "Meat" is just a >>>> label for the class. If this is right, you probably want a query similar to: >>>> >>>> SELECT ?equivalentClass ?meatClass >>>> WHERE { >>>> ?equivalentClass owl:equivalentClass ?meatClass . >>>> ?meatClass rdfs:label "Meat" . >>>> } >>>> >>>> >>>> The details will vary depending on what predicate is used to give a >>>> label to your classes (in my example I assume that it's rdfs:label). Also, >>>> note that the label needs to be exactly "Meat" for this to work. >>>> >>>> hope this helps, >>>> Lee >>>> >>> >>> >>> >> > > > -- > -- > Samuel Pedro > -- -- Samuel Pedro -- -- Samuel Pedro
Received on Friday, 12 June 2009 18:32:01 UTC