Reputation: 139
I have some question on the way of using FILTER
When I used the query as below in the DBPedia SPARQL Endpoint, 1 result was retrieved.
However, if I take FILTER ( langMatches(lang(?sl),'en') && langMatches(lang(?ol),'en') )
off from the query, then, there is nothing retrieved.
I think there should be more results because FILTER
wasn't used.
How can this be possible?
SPARQL Endpoint : dbpedia.org/sparql
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?s ?sl (<http://xmlns.com/foaf/0.1/depiction> as ?p) ?o ?ol
WHERE {
?s rdfs:label ?sl .
?s <http://xmlns.com/foaf/0.1/depiction> ?o .
?o rdfs:label ?ol .
FILTER ( langMatches(lang(?sl),'en') && langMatches(lang(?ol),'en') ) <------- this part
}
LIMIT 100
Upvotes: 2
Views: 1237
Reputation: 85913
This is strange, and I do see the results that you're talking about. You've got a web-service that you can run queries against, and it's easy to modify the query a bit to get more information about what's happening. First, let see how many results there are in total (without the filter):
select (count(*) as ?nResults) where {
?s rdfs:label ?sl .
?s <http://xmlns.com/foaf/0.1/depiction> ?o .
?o rdfs:label ?ol .
}
24
Now, how many are left if we take only those pairs with English labels?
select (count(*) as ?nResults) where {
?s rdfs:label ?sl .
?s <http://xmlns.com/foaf/0.1/depiction> ?o .
?o rdfs:label ?ol .
filter ( langMatches(lang(?sl),'en') && langMatches(lang(?ol),'en') )
}
1
That's promising, since we'd expect the number to decrease when we add additional constraints. Those numbers are also small enough that we don't need to worry about the limit, and we can look at the results directly. First, for the unfiltered results:
select * where {
?s rdfs:label ?sl .
?s <http://xmlns.com/foaf/0.1/depiction> ?o .
?o rdfs:label ?ol .
}
When I run this query, I'd expect to get back 24 result rows, as the first query suggested. When I run it, though, I don't actually get any results. This query seems to take quite a while, and it may be that we're running into some timeouts. In any case, something strange is going on. On to the filtered query:
select * where {
?s rdfs:label ?sl .
?s <http://xmlns.com/foaf/0.1/depiction> ?o .
?o rdfs:label ?ol .
filter ( langMatches(lang(?sl),'en') && langMatches(lang(?ol),'en') )
}
There's just one result, and it's got these values:
s <http://dbpedia.org/resource/Franz_Kruckenberg>
sl "Franz Kruckenberg"@en
o <http://dbpedia.org/resource/Schienenzeppelin>
ol "Schienenzeppelin"@en
Since the count(*)
query in the unfiltered case gives 24, I think that there's something going on here that's not quite right. It might be a time limit though, in which case you might need to download data locally and run your query locally. If it's some other kind of bug, though, you might want to get on the DBpedia mailing list and ask them.
Running some related queries doesn't help things too much. E.g., if you just ask for things that have depictions that have labels, you only get a few results, and they're all about the same resource (Frank Kruckenberg):
select * where {
?s <http://xmlns.com/foaf/0.1/depiction> [ rdfs:label ?dl ]
}
dl s
---------------------------------------------------------------------
"Schienenzeppelin"@de http://dbpedia.org/resource/Franz_Kruckenberg
"Schienenzeppelin"@en http://dbpedia.org/resource/Franz_Kruckenberg
"Schienenzeppelin"@fr http://dbpedia.org/resource/Franz_Kruckenberg
"Schienenzeppelin"@it http://dbpedia.org/resource/Franz_Kruckenberg
"シーネンツェッペリン"@ja http://dbpedia.org/resource/Franz_Kruckenberg
"Schienenzeppelin"@pl http://dbpedia.org/resource/Franz_Kruckenberg
"Рельсовый Цеппелин"@ru http://dbpedia.org/resource/Franz_Kruckenberg
"Schienenzeppelin"@sv http://dbpedia.org/resource/Franz_Kruckenberg
Upvotes: 2