Im a very beginner in sparql, just started doint it a couple hours ago. Howewer, after some practicing i don't know why the following query is not working:
select * where
{
?auth dbp:author dbr:The_Lord_of_the_Rings .
} LIMIT 100
So basically i just want the author of this book, which is a property of it.
Use this
select * where
{
dbr:The_Lord_of_the_Rings dbp:author ?auth .
} LIMIT 100
Update/Correction:
The property dbp:author has the meaning: has_author (and not: is_author_of as it is implied by the positioning of subject and object in the question).
Related
Howto get a list of the top 10 highest mountains from dbpedia ?
I don't know howto start, because I already fail by looking for the correct properties of a specific mountain.
I can't find any property of 'elevation' or 'altitude' in
http://dbpedia.org/page/Mount_Everest
I thought that an interesting property would be the elevation ?
Can someone help ?
This is a problem with publicly curated data, there's no formal schema, so some of the mountains have dbo:elevation (http://dbpedia.org/page/Lhotse) and some only have dbp:elevationRef (http://dbpedia.org/page/K2). You have two options, one technical, one socially beneficial.
Technical option would be a query to get the top 14 and use post processing on the string "(Ranking x)" to get the top 10.
SELECT DISTINCT ?mountain ?rank
WHERE {
?mountain dbp:listing dbr:Eight-thousander.
?mountain dbp:elevationRef ?rank.
}
Socially beneficial solution is to go through those mountains in the Eight-thousander category on Wikipedia and make sure they all have the elevation property set in their description boxes so that DBpedia will scrape it and you can run the query you want:
SELECT DISTINCT ?mountain ?elevation
WHERE {
?mountain dbp:listing dbr:Eight-thousander.
?mountain dbo:elevation ?elevation.
}
ORDER BY DESC(?elevation)
LIMIT 10
Reading the paper "Wikidata through the Eyes of DBpedia" (2015), I came across this SPARQL query:
select * WHERE {
?place wkdt:P31c/wkdt:P279c* wkdt:Q2221906;
wkdt:P17c wkdt:Q183. }
I don't understand what the c means beside the property codes.
The authors explain (page 8, lines 1 and 2) that "querying for reified
statement in Wikidata needs to properly suffix the Wikidata property with c/s/q"
This is the first time I hear about these suffixes and my research on the net does not help.
Could someone tell me more about that ?
I use this sparql query to get as much cities as possible:
select * where {
?city rdf:type dbo:PopulatedPlace
}
However, some expected ones are missing e.g.
http://dbpedia.org/resource/Heidelberg
(neither that nor one of its wikiRedirects)
which is of a dbo:PopulatedPlace as this query returns true (in JSON):
ask {
:Heidelberg a dbo:PopulatedPlace
}
I need that list to be exhaustiv because later I will add constraints based on user input.
I use http://dbpedia.org/snorql/ to test the queries.
Any help is appreciated.
UPDATE:
One of the Devs told me the public endpoint is limited ( about 1K ).
I'll come up with a paginated solution and see if it contains the 'outlier'.
UPDATE2:
The outlier is definitly in the resultset of rdf:type dbo:Town.
Using dbo:PopulatedPlace yields too many results to check per hand, though.
The public endpoint limits results to about 1K. Pagination or use of a smaller subclass of dbo:PopulatedPlace yields the result.
I run a Virtuoso Server and missed a number of results when making a SPARQL-Select request. I tracked it down and find a really strange behaviour, that I cannot explain.
But to start from the beginning.
The endpoint I query can be found at http://creativeartefact.org/sparql
I) Check for a specific triple:
ASK WHERE {
<http://creativeartefact.org/mbrainzImport/f18e677a-4051-486a-aa64-d9a3bfef90af>
<http://creativeartefact.org/ontology/represents>
<http://creativeartefact.org/mbrainzImport/35ed9f2a-6ce4-44ca-9c7a-967377b0e007>. }
The query returns TRUE
II) Now getting a bit more unspecific:
ASK WHERE {
?s
<http://creativeartefact.org/ontology/represents>
<http://creativeartefact.org/mbrainzImport/35ed9f2a-6ce4-44ca-9c7a-967377b0e007>. }
If the first returns true, the second shall do as well, shouldn't it? But it doesn't. It return FALSE!
If I replace the predicate or the object with a variable, it returns true as expected. Only when setting a variable for the subject, it returns false.
That the data really exists in the triple store can be tested by running the query
SELECT * WHERE {
?s
?p
<http://creativeartefact.org/mbrainzImport/35ed9f2a-6ce4-44ca-9c7a-967377b0e007>. }
You will see, that both results comw with p = http://creativeartefact.org/ontology/represents - which is exactly the predicate I am asking for in the former query.
To make it even more strange, there ARE triples with the aforementioned format, that return the triples:
select * {
?s
<http://creativeartefact.org/ontology/represents>
<http://creativeartefact.org/mbrainzImport/e4003568-5645-4ee1-abd0-2e8156272e59>. }
Any idea, what is happening here?
Thanks in advance,
Frank
The Virtuoso being used is an original 07.00.3203 build from 2013.
I would suggest upgrading to the latest Virtuoso 07.10.3211, open source or commercial, depending on which is in use here, and see if the problem persists ...
I have a dataset that looks a bit like:
<item1> <isLocated> <someAddress>
<item2> <isLocated> <someAddress>
<item3> <isLocated> <someOtherAddress>
I want to be able to use SPARQL to answer the question:
"Which items will I find at someAddress or someOtherAddress?"
I could use a UNION like this:
SELECT ?item
{
{ ?item <isLocated> <someAddress> }
UNION { ?item <isLocated> <someOtherAddress }
}
But I think this will become pretty messy when I start talking about 100's or 1000's of addresses.
I think the VALUES inline data might be more suitable than a heap of UNION queries.
I've tried writing the following query but my RDF store/engine (bigdata) seems to choke on it:
SELECT ?item
{
?item <isLocated> ?loc .
}
VALUES (?loc) { (<someAddress>) (<someOtherAddress>) }
(based on http://www.w3.org/TR/sparql11-query/#inline-data)
The error I get from bigdata is:
Lexical error at line 5, column 7. Encountered: " " (32), after : "VALUES"
Am I forming this query correctly?
Is using a UNION or VALUES more appropriate?
It seems no matter how I format this query (based on the w3 examples in the link above) I get similar Lexical errors.
Any ideas?
Cheers.
At a guess, I'd say that Bigdata does not yet support the VALUES clause. This is a brand new feature introduced in the latest SPARQL working draft (published just weeks ago), so quite naturally several tools will not yet support it.
You could try using BINDINGS instead (this is roughly the same feature from previous working drafts, which was replaced).
You've mixed up the syntax a little. Either use:
VALUES ?loc { <someAddress> <someOtherAddress> }
which is a special form for a single variable, or:
VALUES (?loc) { ( <someAddress> ) ( <someOtherAddress> ) }
the general form.
You could also try IN
FILTER (?loc IN ( val1, val2, ...))