问题
i'm trying to use SPARQL query on DBpedia. I can retrieve all information about a resource with this query:
PREFIX db: <http://dbpedia.org/resource/
PREFIX prop: <http://dbpedia.org/property/>
PREFIX onto: <http://dbpedia.org/ontology/>
SELECT ?property ?value
WHERE { db:Luciano_Ligabue ?property ?value };
Now I want to retrieve the value of just one property such as dbpedia-owl: birthDate. I'm trying in different way, but i can't retrieve the information needed.
Can someone help me, please? Thank you guys.
回答1:
You need to show us the exact query you're using. The one you've provided isn't legal SPARQL. The sparql.org validator points out that there should be a >
at the end of PREFIX db: <http://dbpedia.org/resource/
, and that there should be no ;
at the final line. So your query doesn't appear to return what you want it to; it's not even a legal query.
DBpedia is sometimes a bit slow to respond, so I can't test this right now, but it sounds like you just need (I'm using the same prefixes that the DBpedia endpoint uses, because it makes copying and pasting easier, but you've defined db:
instead of dbpedia:
and onto:
instead of dbpedia-owl:
):
select ?value where {
dbpedia:Luciano_Ligabue dbpedia-owl:birthDate ?value
}
回答2:
Is this you are looking for ?
PREFIX dbo: <http://dbpedia.org/resource/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX onto: <http://dbpedia.org/ontology/>
SELECT ?dob ?name ?homepage
WHERE{
dbo:Luciano_Ligabue onto:birthDate ?dob.
dbo:Luciano_Ligabue prop:name ?name.
dbo:Luciano_Ligabue foaf:homepage ?homepage.
}
来源:https://stackoverflow.com/questions/22667987/select-a-property-value-from-dbpedia-resource-with-sparql