从dbpedia检索数据时出错

时间:2013-05-16 15:38:00

标签: java sparql dbpedia

嘿伙计我的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();
    }
}

它不会检索dbpedia所需的数据。 我想从一个特定的dbpedia页面中检索数据

1 个答案:

答案 0 :(得分:1)

您使用错误的IRI来识别页面。它不是page,而是resource。此外,它是图形中的资源,而不是(据我所知)一个命名的图形,因此您不需要查询中的FROM。这是一个有效的查询:

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
}

results有一排,一张北极猴子在MSG玩的照片。