- From: Hugh Glaser <hg@ecs.soton.ac.uk>
- Date: Mon, 21 Mar 2011 13:05:17 +0000
- To: Mischa Tuffield <mmt04r@ecs.soton.ac.uk>
- CC: "<nathan@webr3.org>" <nathan@webr3.org>, Linked Data community <public-lod@w3.org>
Thanks Mischa. On 21 Mar 2011, at 12:40, Mischa Tuffield wrote: > Hi Hugh, > > <snip/> <snip /> >> Best >> Hugh >> >> PS While we are in SPARQL for dummies mode ( :-) ) what is the best way of doing a query for an exact string where I don't care about the language or the datatype? >> I'm sure this is easy in SPARQL 1.1, as there have been so many users who would have needed it. I am hoping that the answer is not regex for such a common thing. > > You can do it in SPARQL 1.0, no need for SPARQL 1.1. You can use the str() function, it strips off all of the language tags and datatypes: > > SELECT ?s > WHERE { ?s rdfs:label ?label . > FILTER (str(?label) = "World Wide Web Consortium") } > > > I would point out that this is a super inefficient query, and will have to walk the entirety of the graph. I have tried to run the query on dbpedia's sparql-endpoint and it doesn't seem to want to answer it, but saying that it is a horrible query to issue to a sparql store. > > Regards, > > Mischa > Yeah Rob Vesse sent me another one with SAMETERM that also times out. It might be horrible (yes it is!), but it is a pretty natural thing to want to do; it is just an exact string match to a normal user. Frankly, I find it pretty unacceptable that the consumer of the data not only needs to know whether lang and datatype has been put in the store (and what choices were made), but we actually make it difficult for them to find out. And when they do it is not a simple pattern. So I guess I need to do four patterns just to find all the exact "World Wide Web Consortium" English phrases (with and without @en and with and without datatype string). Is that really right? Doesn't encourage me to move from SQL. Sometimes I wonder just how many people in the world are actually consuming from datatsets they didn't create themselves, or have taken a lot of trouble to learn about.
Received on Monday, 21 March 2011 13:05:56 UTC