[英]Error with retrieving data from dbpedia
Hey guys I've got a problem with my sparql query can anyone help me. 嗨,我的sparql查询有问题,谁能帮助我。
String queryString =
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
"PREFIX type: <http://dbpedia.org/class/yago/>"+
"PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>"+
"PREFIX prop: <http://dbpedia.org/property/>"+
"PREFIX foaf: <http://xmlns.com/foaf/0.1/>"+
"SELECT "+
"?description "+
"FROM <http://dbpedia.org/page/Arctic_Monkeys> "+
"WHERE " +
"{"+
"?x foaf:depiction ?description."+
"}";
Query query = QueryFactory.create(queryString);
//initializing queryExecution factory with remote service.
QueryExecution qexec=QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
//query execution and result processing
try {
//simple select
ResultSet results = qexec.execSelect();
ResultSetFormatter.out(System.out, results, query);
}
finally{
qexec.close();
}
}
It doesn't retrieve the data needed from dbpedia. 它不会从dbpedia检索所需的数据。 I want to retrieve the data from one specific dbpedia page
我想从一个特定的dbpedia页面检索数据
You've got the wrong IRI for identifying the page. 您识别该页面的IRI错误。 It's not
page
, but resource
. 不是
page
,而是resource
。 Additionally, it's a resource in the graph, not (as far as I know) a named, graph, so you don't need the FROM
in your query. 此外,它是图形中的一种资源,而不是(据我所知)一个命名图形,因此您在查询中不需要
FROM
。 Here's a query that works: 这是一个有效的查询:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?depiction
WHERE {
<http://dbpedia.org/resource/Arctic_Monkeys> foaf:depiction ?depiction
}
The results have one row, a photo of the Arctic Monkeys playing at MSG. 结果有一行,一张在MSG上玩的北极猴子的照片。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.