Re: SPARQL: sorting resources by label?
On Sat, 2010-03-13 at 04:16 +0100, Axel Rauschmayer wrote: OPTIONAL { ?subj ?labelPred ?label . FILTER ( (?labelPred = http://www.w3.org/2000/01/rdf-schema#label) # (1) ) FILTER( isLiteral(?label) ) } I use something like: OPTIONAL { ?subject ?labelprop ?label . GRAPH http://buzzword.org.uk/2009/label-properties { ?labelprop a http://buzzword.org.uk/2009/label-properties#LabelProperty . } FILTER( isLiteral(?label) ) } Having first loaded http://buzzword.org.uk/2009/label-properties into the store. -- Toby A Inkster mailto:m...@tobyinkster.co.uk http://tobyinkster.co.uk
Re: SPARQL: sorting resources by label?
On 14 March 2010 20:04, Toby Inkster t...@g5n.co.uk wrote: I use something like: OPTIONAL { ?subject ?labelprop ?label . GRAPH http://buzzword.org.uk/2009/label-properties { ?labelprop a http://buzzword.org.uk/2009/label-properties#LabelProperty . } FILTER( isLiteral(?label) ) } Having first loaded http://buzzword.org.uk/2009/label-properties into the store. I like your idea of wrapping all the label properties up, but don't you need to run subproperty inference before the query will work? -- http://danny.ayers.name
Re: SPARQL: sorting resources by label?
On Sun, 2010-03-14 at 21:01 +0100, Danny Ayers wrote: On 14 March 2010 20:04, Toby Inkster t...@g5n.co.uk wrote: I use something like: OPTIONAL { ?subject ?labelprop ?label . GRAPH http://buzzword.org.uk/2009/label-properties { ?labelprop a http://buzzword.org.uk/2009/label-properties#LabelProperty . } FILTER( isLiteral(?label) ) } Having first loaded http://buzzword.org.uk/2009/label-properties into the store. I like your idea of wrapping all the label properties up, but don't you need to run subproperty inference before the query will work? Assuming that the label property being used is listed at http://buzzword.org.uk/2009/label-properties, then it works without any inferencing. If the label property being used is a rdfs:subPropertyOf or owl:equivalentProperty of one of the listed properties, then, yes, inferencing is needed of course. But frankly, anybody using a labelling property that's not listed there deserves everything they get! -- Toby A Inkster mailto:m...@tobyinkster.co.uk http://tobyinkster.co.uk
SPARQL: sorting resources by label?
The closest I get is the following SPARQL query: SELECT DISTINCT ?subj ?label WHERE { GRAPH ?graph { ?subj ?pred ?obj . OPTIONAL { ?subj ?labelPred ?label . FILTER ( (?labelPred = http://www.w3.org/2000/01/rdf-schema#label) # (1) ) FILTER( isLiteral(?label) ) } } FILTER (?graph = http://hypergraphs.de/TestGraph) } ORDER BY ?label ?subj Comments: - This solution also works for multiple label predicates (i.e., if there are subproperties of rdfs:label), then the unary disjunction (1) has more components. - ?graph is necessary, because Sesame does not support datasets and I want to restrict the query to all graphs that are currently visible. - This query returns unlabeled resources first (?label is unbound), then labeled resources. Better would be to show labeled resources first. Best would be to mix them, where unlabeled resources are sorted according to their qname. Can this be improved? Thanks for any comments or suggestions... Axel -- axel.rauschma...@ifi.lmu.de http://www.pst.ifi.lmu.de/~rauschma/
Re: SPARQL: sorting resources by label?
On 13 March 2010 04:16, Axel Rauschmayer a...@rauschma.de wrote: Thanks for any comments or suggestions... I'm a little perturbed that you have to use something so convoluted to get labels Why not something just like (whatever graph) SELECT ?o WHERE { ?s rdfs:label ?o } , or at worse an OPTIONAL on maybe dc:label or whatever..? - are the objects of any labels resources? Can you please clarify what you are looking for, and explain further - I honestly hope you are missing something there. If there is something wrong with the material, the problems should be surfaced and fixed (and no doubt will be for the next rev, if need be) Cheers, Danny. http://danny.ayers.name
Re: SPARQL: sorting resources by label?
I have a GUI data structure that is a pair (resource, label). The label is used for humans, the resource is used to process RDF. If I want SPARQL to produce list of these pairs ordered by label, this is the simplest query that I can think of. This is but a start, I will later insert more FILTERs (for faceted navigation etc.). Axel On Mar 13, 2010, at 4:51 , Danny Ayers wrote: On 13 March 2010 04:16, Axel Rauschmayer a...@rauschma.de wrote: Thanks for any comments or suggestions... I'm a little perturbed that you have to use something so convoluted to get labels Why not something just like (whatever graph) SELECT ?o WHERE { ?s rdfs:label ?o } , or at worse an OPTIONAL on maybe dc:label or whatever..? - are the objects of any labels resources? Can you please clarify what you are looking for, and explain further - I honestly hope you are missing something there. If there is something wrong with the material, the problems should be surfaced and fixed (and no doubt will be for the next rev, if need be) Cheers, Danny. http://danny.ayers.name -- axel.rauschma...@ifi.lmu.de http://www.pst.ifi.lmu.de/~rauschma/
Re: SPARQL: sorting resources by label?
Addendum: If one wants to produce a table | URI | label | types | SPARQL becomes even more unwieldy. Just think of sorting the type column by the label of the types. Or even of producing a Java object for each row. The problem is that SPARQL does not support query rows in NFNF. Maybe DESCRIBE can be used in the future for this? Axel On Mar 13, 2010, at 4:51 , Danny Ayers wrote: On 13 March 2010 04:16, Axel Rauschmayer a...@rauschma.de wrote: Thanks for any comments or suggestions... I'm a little perturbed that you have to use something so convoluted to get labels Why not something just like (whatever graph) SELECT ?o WHERE { ?s rdfs:label ?o } , or at worse an OPTIONAL on maybe dc:label or whatever..? - are the objects of any labels resources? Can you please clarify what you are looking for, and explain further - I honestly hope you are missing something there. If there is something wrong with the material, the problems should be surfaced and fixed (and no doubt will be for the next rev, if need be) Cheers, Danny. http://danny.ayers.name -- axel.rauschma...@ifi.lmu.de http://www.pst.ifi.lmu.de/~rauschma/